| 442 | } |
| 443 | |
| 444 | void Console::timeCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 445 | try { |
| 446 | auto isolate = info.GetIsolate(); |
| 447 | |
| 448 | v8::HandleScope scope(isolate); |
| 449 | |
| 450 | auto argLen = info.Length(); |
| 451 | std::string label = "default"; |
| 452 | |
| 453 | v8::Local<v8::String> argString; |
| 454 | if (argLen && info[0]->ToString(isolate->GetCurrentContext()).ToLocal(&argString)) { |
| 455 | label = ArgConverter::ConvertToString(argString); |
| 456 | } |
| 457 | |
| 458 | auto it = Console::s_isolateToConsoleTimersMap.find(isolate); |
| 459 | if (it == Console::s_isolateToConsoleTimersMap.end()) { |
| 460 | // throw? |
| 461 | } |
| 462 | |
| 463 | auto nano = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()); |
| 464 | double timeStamp = nano.time_since_epoch().count(); |
| 465 | |
| 466 | it->second.insert(std::make_pair(label, timeStamp)); |
| 467 | } catch (NativeScriptException& e) { |
| 468 | e.ReThrowToV8(); |
| 469 | } catch (std::exception e) { |
| 470 | std::stringstream ss; |
| 471 | ss << "Error: c++ exception: " << e.what() << std::endl; |
| 472 | NativeScriptException nsEx(ss.str()); |
| 473 | nsEx.ReThrowToV8(); |
| 474 | } catch (...) { |
| 475 | NativeScriptException nsEx(std::string("Error: c++ exception!")); |
| 476 | nsEx.ReThrowToV8(); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | void Console::timeEndCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 481 | try { |
nothing calls this directly
no test coverage detected