Debian Codegraph @

js/src/devtools/gc-ubench/spidermonkey.js

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 // SpiderMonkey JS shell benchmark script
6 //
7 // Usage: run $JS spidermonkey.js --help
8
9 loadRelativeToScript("shell-bench.js");
10
11 var SpiderMonkey = class extends Host {
12 start_turn() {}
13
14 end_turn() {
15 clearKeptObjects();
16 maybegc();
17 drainJobQueue();
18 }
19
20 suspend(duration) {
21 sleep(duration);
22 }
23
24 get minorGCCount() {
25 return performance.mozMemory.gc.minorGCCount;
26 }
27 get majorGCCount() {
28 return performance.mozMemory.gc.majorGCCount;
29 }
30 get GCSliceCount() {
31 return performance.mozMemory.gc.sliceCount;
32 }
33 get gcBytes() {
34 return performance.mozMemory.gc.zone.gcBytes;
35 }
36 get gcAllocTrigger() {
37 return performance.mozMemory.gc.zone.gcAllocTrigger;
38 }
39
40 features = {
41 haveMemorySizes: true,
42 haveGCCounts: true,
43 };
44 };
45
46 var gHost = new SpiderMonkey();
47 var { opts, rest: mutators } = argparse.parse_args(scriptArgs);
48 run(opts, mutators);
49
50 print("\nTest results:\n");
51 report_results();
52
53 var outfile = "spidermonkey-results.json";
54 var origOut = redirect(outfile);
55 print(JSON.stringify(gPerf.results));
56 redirect(origOut);
57 print(`Wrote detailed results to ${outfile}`);