Skip to content

Instantly share code, notes, and snippets.

@neonux
Created September 15, 2011 20:06
Show Gist options
  • Save neonux/1220322 to your computer and use it in GitHub Desktop.
Save neonux/1220322 to your computer and use it in GitHub Desktop.
dumps before and after calling foo()
=== BEFORE FOO() ===
--- SCRIPT :0 ---
loc counts x line op
----- ---------------- ---- --
main:
00000:0/0/0/0/0/0 x 0 stop
--- END SCRIPT :0 ---
--- SCRIPT :0 ---
loc counts x line op
----- ---------------- ---- --
main:
00000:0/0/0/0/0/0 x 0 stop
--- END SCRIPT :0 ---
--- SCRIPT file:///home/cedric/tmp/demo/demo.js:1 ---
loc counts x line op
----- ---------------- ---- --
main:
00000:0/0/0/0/0/0 x 2 getgname "console"
00003:0/0/0/0/0/0 x 2 callprop "log"
00006:0/0/0/0/0/0 x 2 string "foo"
00009:0/0/0/0/0/0 x 2 call 1
00012:0/0/0/0/0/0 x 2 pop
00013:0/0/0/0/0/0 x 2 stop
--- END SCRIPT file:///home/cedric/tmp/demo/demo.js:1 ---
--- SCRIPT file:///home/cedric/tmp/demo/demo.js:5 ---
loc counts x line op
----- ---------------- ---- --
main:
00000:0/0/0/0/0/0 x 6 getgname "console"
00003:0/0/0/0/0/0 x 6 callprop "log"
00006:0/0/0/0/0/0 x 6 string "b"
00009:0/0/0/0/0/0 x 6 call 1
00012:0/0/0/0/0/0 x 6 pop
00013:0/0/0/0/0/0 x 7 getgname "console"
00016:0/0/0/0/0/0 x 7 callprop "log"
00019:0/0/0/0/0/0 x 7 string "a"
00022:0/0/0/0/0/0 x 7 call 1
00025:0/0/0/0/0/0 x 7 pop
00026:0/0/0/0/0/0 x 8 getgname "console"
00029:0/0/0/0/0/0 x 8 callprop "log"
00032:0/0/0/0/0/0 x 8 string "r"
00035:0/0/0/0/0/0 x 8 call 1
00038:0/0/0/0/0/0 x 8 pop
00039:0/0/0/0/0/0 x 8 stop
--- END SCRIPT file:///home/cedric/tmp/demo/demo.js:5 ---
--- SCRIPT file:///home/cedric/tmp/demo/demo.js:1 ---
loc counts x line op
----- ---------------- ---- --
main:
00000:1/0/0/0/0/0 x 1 nop
00001:1/0/0/0/0/0 x 5 nop
00002:1/0/0/0/0/0 x 11 getgname "document"
00005:1/0/0/0/0/0 x 11 callprop "getElementById"
00008:1/0/0/0/0/0 x 11 string "foo"
00011:1/0/0/0/0/0 x 11 call 1
00014:1/0/0/0/0/0 x 11 callprop "addEventListener"
00017:1/0/0/0/0/0 x 11 string "click"
00020:1/0/0/0/0/0 x 11 getglobal "foo"
00023:1/0/0/0/0/0 x 11 false
00024:1/0/0/0/0/0 x 11 call 3
00027:1/0/0/0/0/0 x 11 pop
00028:1/0/0/0/0/0 x 12 getgname "document"
00031:1/0/0/0/0/0 x 12 callprop "getElementById"
00034:1/0/0/0/0/0 x 12 string "bar"
00037:1/0/0/0/0/0 x 12 call 1
00040:1/0/0/0/0/0 x 12 callprop "addEventListener"
00043:1/0/0/0/0/0 x 12 string "click"
00046:1/0/0/0/0/0 x 12 getglobal "bar"
00049:1/0/0/0/0/0 x 12 false
00050:1/0/0/0/0/0 x 12 call 3
00053:1/0/0/0/0/0 x 12 pop
00054:1/0/0/0/0/0 x 12 stop
--- END SCRIPT file:///home/cedric/tmp/demo/demo.js:1 ---
=== AFTER FOO() ===
--- SCRIPT :0 ---
loc counts x line op
----- ---------------- ---- --
main:
00000:0/0/0/0/0/0 x 0 stop
--- END SCRIPT :0 ---
--- SCRIPT :0 ---
loc counts x line op
----- ---------------- ---- --
main:
00000:0/0/0/0/0/0 x 0 stop
--- END SCRIPT :0 ---
--- SCRIPT file:///home/cedric/tmp/demo/demo.js:1 ---
loc counts x line op
----- ---------------- ---- --
main:
00000:1/0/0/0/0/0 x 2 getgname "console"
00003:1/0/0/0/0/0 x 2 callprop "log"
00006:1/0/0/0/0/0 x 2 string "foo"
00009:1/0/0/0/0/0 x 2 call 1
00012:1/0/0/0/0/0 x 2 pop
00013:1/0/0/0/0/0 x 2 stop
--- END SCRIPT file:///home/cedric/tmp/demo/demo.js:1 ---
--- SCRIPT file:///home/cedric/tmp/demo/demo.js:5 ---
loc counts x line op
----- ---------------- ---- --
main:
00000:0/0/0/0/0/0 x 6 getgname "console"
00003:0/0/0/0/0/0 x 6 callprop "log"
00006:0/0/0/0/0/0 x 6 string "b"
00009:0/0/0/0/0/0 x 6 call 1
00012:0/0/0/0/0/0 x 6 pop
00013:0/0/0/0/0/0 x 7 getgname "console"
00016:0/0/0/0/0/0 x 7 callprop "log"
00019:0/0/0/0/0/0 x 7 string "a"
00022:0/0/0/0/0/0 x 7 call 1
00025:0/0/0/0/0/0 x 7 pop
00026:0/0/0/0/0/0 x 8 getgname "console"
00029:0/0/0/0/0/0 x 8 callprop "log"
00032:0/0/0/0/0/0 x 8 string "r"
00035:0/0/0/0/0/0 x 8 call 1
00038:0/0/0/0/0/0 x 8 pop
00039:0/0/0/0/0/0 x 8 stop
--- END SCRIPT file:///home/cedric/tmp/demo/demo.js:5 ---
@davidflanagan
Copy link

function heatClass(counts) {
function log(x) {
if (x <= 0) return 0;
return Math.min(Math.floor(Math.log(x)/Math.LN10), 9);
}

var count = counts[counts.length-1];  // the last one is biggest
return " p" + log(count);

};

.p0 {color:#000;}
.p1 {color:#200;}
.p2 {color:#400;}
.p3 {color:#600;}
.p4 {color:#800;}
.p5 {color:#a00;}
.p6 {color:#c00;}
.p7 {color:#e00;}
.p8 {color:#f00;}
.p9 {color:#f00;}

@davidflanagan
Copy link

function heatClass(counts) {
    function log(x) {
        if (x <= 0) return 0;
        return Math.min(Math.floor(Math.log(x)/Math.LN10), 9);
    }

    var count = counts[counts.length-1];  // the last one is biggest
    return " p" + log(count);
};


.p0 {color:#000;}
.p1 {color:#200;}
.p2 {color:#400;}
.p3 {color:#600;}
.p4 {color:#800;}
.p5 {color:#a00;}
.p6 {color:#c00;}
.p7 {color:#e00;}
.p8 {color:#f00;}
.p9 {color:#f00;}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment