@@ -31,37 +31,17 @@ INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()
3131 });
3232
3333TEST_P(TestVm, Init) {
34- std::chrono::time_point<std::chrono::steady_clock> time2;
35-
3634 auto time1 = std::chrono::steady_clock::now();
37- if (engine_ == "v8") {
38- #if defined(PROXY_WASM_HOST_ENGINE_V8)
39- EXPECT_TRUE(proxy_wasm::initV8Engine());
40- time2 = std::chrono::steady_clock::now();
41- EXPECT_TRUE(proxy_wasm::initV8Engine());
42- #endif
43- } else if (engine_ == "wamr") {
44- #if defined(PROXY_WASM_HOST_ENGINE_WAMR)
45- EXPECT_TRUE(proxy_wasm::initWamrEngine());
46- time2 = std::chrono::steady_clock::now();
47- EXPECT_TRUE(proxy_wasm::initWamrEngine());
48- #endif
49- } else if (engine_ == "wasmtime") {
50- #if defined(PROXY_WASM_HOST_ENGINE_WASMTIME)
51- EXPECT_TRUE(proxy_wasm::initWasmtimeEngine());
52- time2 = std::chrono::steady_clock::now();
53- EXPECT_TRUE(proxy_wasm::initWasmtimeEngine());
54- #endif
55- } else {
56- return;
57- }
35+ vm_->warm();
36+ auto time2 = std::chrono::steady_clock::now();
37+ vm_->warm();
5838 auto time3 = std::chrono::steady_clock::now();
5939
6040 auto cold = std::chrono::duration_cast<std::chrono::nanoseconds>(time2 - time1).count();
6141 auto warm = std::chrono::duration_cast<std::chrono::nanoseconds>(time3 - time2).count();
6242
63- std::cout << "\"cold\" engine time: " << cold << "ns" << std::endl;
64- std::cout << "\"warm\" engine time: " << warm << "ns" << std::endl;
43+ std::cout << "[" << engine_ << "] \"cold\" engine time: " << cold << "ns" << std::endl;
44+ std::cout << "[" << engine_ << "] \"warm\" engine time: " << warm << "ns" << std::endl;
6545
6646 // Default warm time in nanoseconds.
6747 int warm_time_ns_limit = 10000;
@@ -75,6 +55,11 @@ TEST_P(TestVm, Init) {
7555 EXPECT_LE(warm, warm_time_ns_limit);
7656
7757 // Verify that getting a "warm" engine takes at least 50x less time than getting a "cold" one.
58+ // We skip NullVM because warm() is a noop.
59+ if (engine_ == "null") {
60+ std::cout << "Skipping warm() performance assertions for NullVM." << std::endl;
61+ return;
62+ }
7863 EXPECT_LE(warm * 50, cold);
7964}
8065
0 commit comments