Skip to content

Instantly share code, notes, and snippets.

@nbp
nbp / reverseForEach.cc
Created July 16, 2015 21:43
Iterative variadic templates
#define METHOD 1
// I admit this is not an easy function to understand, but you will love it
// in a few seconds.
void reverseForEach(...) { }
#if METHOD == 1
// This method use a separate data structure as an accumulator, and call a
// method to mutate the content of the accumulator. If you don't see any
@nbp
nbp / idle-monitor.bt
Created September 25, 2019 17:03
Attempt to measure the time taken between 3 events within Firefox (OnIncrementalData, OnStreamComplete and ExecScript)
#!/usr/bin/env bpftrace
//
// idle-monitor Records amount of time the CPU is idle in-between 2 events.
//
// USAGE: idle-monitor.bt
//
// Monitor when CPUs are entering the idle state, and record the associated timestamp.
kprobe:rcu_idle_enter {
@cpuIdleCount[cpu] = nsecs
@nbp
nbp / Idle-time-percent.txt
Created September 26, 2019 12:58
Idle time percent while fetching, and before executing JS code.
@idle_bw_fetch_end_and_exec_start:
(..., 0) 51 |@@ |
[0] 145 |@@@@@@@@ |
[1] 0 | |
[2, 4) 0 | |
[4, 8) 0 | |
[8, 16) 0 | |
[16, 32) 0 | |
[32, 64) 0 | |
[64, 128) 0 | |
@nbp
nbp / zero-width-whitespace.js
Last active October 8, 2019 12:56
zero-width-whitespaces are valid identifier names in JavaScript
a‌b = 1;
ab = 2;
a‍b = 3;
console.log(`ab = ${ab}, a‌b = ${a‌b}, a‍b = ${a‍b}`);
Script :
StatementList?
Module :
StatementList?
StatementList :
Statement
StatementList Statement
@nbp
nbp / 20190416.js
Last active November 27, 2019 19:40
Compare parser implemented in SpiderMonkey
// This file should be copied to the top-level directory of real-js-samples to
// compare the legacy parser with the rust parser.
var dir = "20190416";
var mode = "script";
var runs_per_script = 1;
var filter_out = [
"sw.js",
"1202200111%3Fmkt%3Den-GB%26it%3DZ%2CL%2CLA%26og%3D409%26cb%3DMicrosoft.Maps.NetworkCallbacks.normal%26jsonso%3D3c45c%26js%3D1%26tj%3D1%26lc%3D%26c4w%3D1%26vpt%3De%2Cp%2Cpg%26osm%3D1",
"PushService.js%3F1904121404450000",