MCPcopy Create free account
hub / github.com/Snapchat/Valdi / doBench

Function doBench

valdi/test/benchmark/ProtobufBenchmark.cpp:52–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50};
51
52static 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
70static void DecodeQuickJS(benchmark::State& state) {
71 doBench(JavaScriptEngineType::QuickJS, "makeDecoder", state);

Callers 8

DecodeQuickJSFunction · 0.85
DecodeJSCoreFunction · 0.85
EncodeQuickJSFunction · 0.85
EncodeJSCoreFunction · 0.85
DecodeAndVisitQuickJSFunction · 0.85
DecodeAndVisitJSCoreFunction · 0.85
DecodeAndVisitMapQuickJSFunction · 0.85
DecodeAndVisitMapJSCoreFunction · 0.85

Calls 8

getProtoDataMethod · 0.80
getMapValueMethod · 0.80
getJavaScriptRuntimeMethod · 0.80
valueMethod · 0.65
getFunction · 0.50
ValueInterface · 0.50
getFunctionRefMethod · 0.45

Tested by

no test coverage detected