tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

telemetry.js (1586B)


      1 // Test GC telemetry.
      2 
      3 gczeal(0);
      4 gcparam('perZoneGCEnabled', 1);
      5 gcparam('incrementalGCEnabled', 1);
      6 gc();
      7 
      8 function runAndGetTelemetry(probe, thunk) {
      9  startRecordingTelemetry(probe);
     10  thunk();
     11  let samples = getTelemetrySamples(probe);
     12  stopRecordingTelemetry(probe);
     13  return samples;
     14 }
     15 
     16 function checkTelemetry(probe, expected, thunk) {
     17  let samples = runAndGetTelemetry(probe, thunk);
     18  assertEq(samples.length, 1);
     19  assertEq(samples[0], expected);
     20 }
     21 
     22 function incrementalGC() {
     23  startgc(1);
     24  while (gcstate() != 'NotActive') {
     25    gcslice(10000);
     26  }
     27 }
     28 
     29 checkTelemetry('GC_IS_COMPARTMENTAL', 0, () => gc());
     30 checkTelemetry('GC_IS_COMPARTMENTAL', 1, () => gc(this));
     31 
     32 // By default there are two zones, the one for |this| and this atoms zone.
     33 checkTelemetry('GC_ZONE_COUNT', 2, () => gc());
     34 
     35 checkTelemetry('GC_ZONES_COLLECTED', 2, () => gc());
     36 checkTelemetry('GC_ZONES_COLLECTED', 1, () => gc(this));
     37 
     38 checkTelemetry('GC_RESET', 0, () => gc());
     39 checkTelemetry('GC_RESET', 0, () => { startgc(1); finishgc(); });
     40 checkTelemetry('GC_RESET', 1, () => { startgc(1); abortgc(); });
     41 
     42 checkTelemetry('GC_NON_INCREMENTAL', 1, () => gc());
     43 checkTelemetry('GC_NON_INCREMENTAL', 1, () => { startgc(1); abortgc(); });
     44 checkTelemetry('GC_NON_INCREMENTAL', 0, () => { startgc(1); finishgc(); });
     45 checkTelemetry('GC_NON_INCREMENTAL', 0, () => incrementalGC());
     46 
     47 // GC_SLICE_COUNT is not reported for non-incremental GCs.
     48 let samples = runAndGetTelemetry('GC_SLICE_COUNT', () => gc());
     49 assertEq(samples.length, 0);
     50 
     51 checkTelemetry('GC_SLICE_COUNT', 2, () => { startgc(1); finishgc(); });