Message from JavaScript talks

May 2017

— Wonderful explanation. Thanks

— 

C:

#include <stdio.h>
#include <time.h>

int num () {
return 4;
}

int main () {
int n = 1000000;
clock_t start = clock();

while(n > 0) {
num();
n--;
}

clock_t diff = clock() - start;

int ms = diff * 1000 / CLOCKS_PER_SEC;
printf("runtime: %dms", ms);
}

— JavaScript:

"use strict";

function num () {
return 4;
}

let n = 1000000;

console.time("runtime");

while (n > 0) {
num();
n--;
}

console.timeEnd("runtime");

Message permanent page

— 

$ gcc test.c -o test
$ ./test
runtime: 2ms
$ node test.js
runtime: 1.122ms

— Obviously not the best way to test performance

— But gives you an idea at least

— Yeah!

— Depends eh

— Usually these things just build a string and eval it

— Nope

— Not This one

— Building a string is cheap af obfuscation