This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let start = (new Date()).getTime() | |
setTimeout(function() { | |
let end = (new Date()).getTime() | |
console.log(end - start ) | |
}, 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.time("timer") | |
setTimeout(function() { | |
console.timeEnd("timer") | |
}, 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const { | |
performance, | |
PerformanceObserver | |
} = require('perf_hooks'); | |
const mod = require('module'); | |
// Monkey patch the require function | |
mod.Module.prototype.require = performance.timerify(mod.Module.prototype.require); | |
require = performance.timerify(require); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const obs = new PerformanceObserver((list) => { | |
const entry = list.getEntries()[0] | |
console.log(`require('${entry[0]}')`, entry.duration); | |
}); | |
obs.observe({ entryTypes: ['function'], buffered: false}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const { | |
performance, | |
PerformanceObserver | |
} = require('perf_hooks'); | |
const request = require("request") | |
function queryEngines(done) { | |
const urls = [ | |
"http://www.google.com", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const { | |
performance, | |
PerformanceObserver | |
} = require('perf_hooks'); | |
const async_hooks = require("async_hooks") | |
const request = require("request") | |
const map = new Map() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init(id, type, triggerID, resource) { | |
let meta = { | |
event: "[init]", | |
type, id, triggerID | |
} | |
fs.writeFileSync("./perf.log", JSON.stringify(meta) + "\n\t", {flag: "a"} ) | |
for(let p in resource) { | |
if(typeof(resource[p]) != "function") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const READ_TOKEN = "your-read-api-key" | |
const WRITE_TOKEN = 'your-write-api-key' | |
const express = require("express") | |
const butter = require("buttercms")(READ_TOKEN) //read | |
const request = require("request") | |
const bodyParser = require("body-parser") | |
const {Translate} = require('@google-cloud/translate'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WRITE_TOKEN = 'your-buttercms-write-api-key' | |
const express = require("express") | |
const request = require("request") | |
const bodyParser = require("body-parser") | |
const slug = require("slug") | |
const app = express(); | |
app.use(bodyParser.urlencoded({extended: true})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myArray1 = [1,2,3] | |
let myString = "Hey planet!" | |
let myObject = { | |
name: "Fernando Doglio", | |
age: 35, | |
country: "Uruguay", | |
[Symbol.iterator]: function* () { //we're making the object iterable so we can spread it | |
yield myObject.name | |
yield myObject.age | |
yield myObject.country |