This file contains hidden or 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
// for browsers, ya silly! | |
performance.mark('start-party'); | |
runThePartyAnimation(); | |
performance.mark('end-party'); | |
performance.measure('party-measure', 'start-party', 'end-party'); | |
const measure = performance.getEntriesByType('measure')[0]; |
This file contains hidden or 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
function hrMillis(measure) { | |
return (measure[0] * 1000) + (measure[1] / 1e6); | |
} | |
const databaseStartTime = process.hrtime(); | |
await runTheDatabaseCall(); | |
const databaseMeasure = process.hrtime(databaseStartTime); | |
const analyticsStartTime = process.hrtime(); | |
await analyticsCall(); |
This file contains hidden or 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
function hrMillis(measure) { | |
return (measure[0] * 1000) + (measure[1] / 1e6); | |
} | |
const millis = hrMillis(endTime); | |
console.log(millis); | |
// 8210.181641 |
This file contains hidden or 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 startTime = process.hrtime(); | |
await runTheDatabaseCall(); | |
const endTime = process.hrtime(startTime); | |
console.log(endTime); | |
// [ 8, 210181641 ] |
This file contains hidden or 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 iopipeLib = require('iopipe'); | |
const tracePlugin = require('iopipe-plugin-trace'); | |
const iopipe = iopipeLib({ | |
plugins: [tracePlugin()] | |
}); | |
// wrap your lambda handler | |
exports.handler = iopipe((event, context) => { | |
const mark = context.iopipe.mark; |
This file contains hidden or 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 wrapper = "require('iopipe')({token: 'TOKEN'})(REPLACE)"; | |
shift(wrapper) | |
.find(shift.Identifier, { | |
name: 'REPLACE' | |
}) | |
.replaceWith(found); |
This file contains hidden or 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
exports | |
.handler = // 😎 this will work too |
This file contains hidden or 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
exports.handler = //anything here |
This file contains hidden or 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 shift = require('jscodeshift'); | |
const code = 'The string literal of the code to transform (from above)'; | |
const searchObject = { | |
left: { | |
type: 'MemberExpression', | |
object: { | |
type: 'Identifier', | |
name: 'exports' | |
}, | |
property: { |
This file contains hidden or 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 uuid = require('uuid'); | |
const iopipe = require('iopipe')({token: 'TOKEN'}); | |
exports.handler = iopipe((event, context, callback) => { | |
const response = { | |
statusCode: 200, | |
body: JSON.stringify({ | |
message: 'Your uuid is: ' + uuid.v4(), | |
input: event | |
}) | |
}; |