| 50 | }; |
| 51 | |
| 52 | static void doBench(JavaScriptEngineType jsEngineType, std::string_view functionName, benchmark::State& state) { |
| 53 | RuntimeWrapper wrapper(JavaScriptBridge::get(jsEngineType)); |
| 54 | auto bytes = wrapper.getProtoData("card_51.data"); |
| 55 | |
| 56 | auto moduleFunction = wrapper.benchmarkModule.getMapValue(functionName).getFunctionRef(); |
| 57 | |
| 58 | wrapper.runtime->getJavaScriptRuntime()->dispatchOnJsThreadSync(nullptr, [&](const auto& jsEntry) { |
| 59 | auto doBench = (*moduleFunction)(ValueFunctionFlagsPropagatesError, |
| 60 | {Value(makeShared<ValueTypedArray>(Uint8Array, bytes))}) |
| 61 | .value() |
| 62 | .getFunctionRef(); |
| 63 | |
| 64 | for (auto _ : state) { |
| 65 | (*doBench)(ValueFunctionFlagsPropagatesError, {}); |
| 66 | } |
| 67 | }); |
| 68 | } |
| 69 | |
| 70 | static void DecodeQuickJS(benchmark::State& state) { |
| 71 | doBench(JavaScriptEngineType::QuickJS, "makeDecoder", state); |
no test coverage detected