michael@0: function spin_loop() michael@0: { michael@0: for (let i = 0; i < 10000; i++) ; michael@0: } michael@0: michael@0: function check_timing(label, count) { michael@0: if (count == -1) { michael@0: print("TEST-UNEXPECTED-FAIL | TestPerf | " + label); michael@0: throwError(); michael@0: } else { michael@0: print("TEST-PASS | TestPerf | " + label + " = " + count); michael@0: } michael@0: } michael@0: michael@0: var pm = new PerfMeasurement(PerfMeasurement.ALL); michael@0: if (pm.eventsMeasured == 0) { michael@0: print("TEST-KNOWN-FAIL | perf-smoketest | stub, skipping test"); michael@0: } else { michael@0: pm.start(); michael@0: spin_loop(); michael@0: pm.stop(); michael@0: michael@0: check_timing("cpu_cycles", pm.cpu_cycles); michael@0: check_timing("instructions", pm.instructions); michael@0: check_timing("cache_references", pm.cache_references); michael@0: check_timing("cache_misses", pm.cache_misses); michael@0: check_timing("branch_instructions", pm.branch_instructions); michael@0: check_timing("branch_misses", pm.branch_misses); michael@0: check_timing("bus_cycles", pm.bus_cycles); michael@0: check_timing("page_faults", pm.page_faults); michael@0: check_timing("major_page_faults", pm.major_page_faults); michael@0: check_timing("context_switches", pm.context_switches); michael@0: check_timing("cpu_migrations", pm.cpu_migrations); michael@0: }