Install depot_tools
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ export PATH=`pwd`/depot_tools:"$PATH"
Build v8
$ fetch v8
| var fs = require('fs') | |
| for (var i = 0; i < 10000; i++) { | |
| printLength(__filename) | |
| } | |
| function printLength (filename) { | |
| fs.readFile(filename, foo) | |
| function foo (err, buf) { |
| function valuesFn (array) { | |
| var i = 0 | |
| return function foo (abort, cb) { | |
| if(i >= array.length) | |
| cb(true) | |
| else | |
| cb(null, array[i++]) | |
| } | |
| } |
| var fs = { | |
| readFile: function(filename, cb) { | |
| cb(null, {length: 12}); | |
| } | |
| } | |
| for (var i = 0; i < 10000; i++) { | |
| var __filename = 'perf-test.js'; | |
| printLength(__filename) | |
| } |
| function isPrime(p) { | |
| const upper = Math.sqrt(p); | |
| for(let i = 2; i <= upper; i++) { | |
| if (p % i === 0 ) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } |
| const js = require('./primes.js'); | |
| const addon = require('./build/Release/primes.node'); | |
| function run(i) { | |
| console.time('Prime in js'); | |
| js.prime(i); | |
| console.timeEnd('Prime in js'); | |
| console.time('Prime in addon'); | |
| addon.prime(i); |
| #include <napi.h> | |
| #include <math.h> | |
| namespace primes { | |
| // Implementation of isPrime() and prime() omitted. See | |
| // https://github.com/fhinkel/javascript-vs-native-addon-prime-numbers/blob/master/primes.cc | |
| Napi::Value Method(const Napi::CallbackInfo& info) { | |
| Napi::Env env = info.Env(); |
| { | |
| "name": "profiler-issue", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "index.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "author": "", | |
| "license": "ISC", |
| 'use strict'; | |
| const Compute = require('@google-cloud/compute'); | |
| const http = require('http'); | |
| const compute = new Compute(); | |
| const zone = compute.zone('us-central1-a'); | |
| // Create a new VM, using default ubuntu image. The startup script |
| // Run `npm install @google-cloud/compute` first. | |
| const Compute = require('@google-cloud/compute'); | |
| const compute = new Compute(); | |
| // Creates a new VM using the latest Ubuntu image. | |
| (async () => { | |
| try { | |
| const zone = await compute.zone('us-central1-a'); | |
| const data = await zone.createVM( | |
| 'ubuntu-instance', |