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
#################################### | |
########### VARIABLES ############## | |
#################################### | |
GCP_PROJECT="YOUR_PROJECT_ID" | |
SERVICE_NAME="my-react-app" | |
REGION="europe-west1" | |
#################################### | |
###### GENERATED VARIABLES ######### | |
#################################### |
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
#################################### | |
########### VARIABLES ############## | |
#################################### | |
GCP_PROJECT="YOUR_PROJECT_ID" | |
SERVICE_NAME="my-react-app" | |
REGION="europe-west1" | |
#################################### | |
###### GENERATED VARIABLES ######### | |
#################################### |
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 {measureSync, measureAsync} = require('easy-performance-measure'); | |
// 1. Create a synchronous method to measure | |
/** | |
* Add values | |
* @param count | |
* @return {number} | |
*/ | |
const syncFn = (count) => { | |
let l = 0; |
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 myMethod = () => { | |
const startTimeInMs = new Date().getTime(); | |
// Do some heavy computation | |
// .......... | |
// //////////////////////////////////////// | |
const endTimeInMs = new Date().getTime(); | |
const durationInMs = endTimeInMs - startTimeInMs; |
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
/** | |
* Measures the time in milliseconds it takes for the passed in method to finish | |
* @param {function} fn The method which should be measured | |
* @param {Array<unknown>} args A dynamic amount of parameters which will be passed into 'fn' | |
* @return {Promise<[unknown, number]>} A tuple where the first element is the response of the passed in method and the | |
* second the time in milliseconds it took to complete | |
*/ | |
export declare const measureAsync: <T, G extends unknown[]>(fn: (...args: G) => Promise<T>, ...args: G) => Promise<[T, number]>; | |
/** | |
* Measures the time in milliseconds it takes for the passed in method to finish |
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
measureSync(syncFn, 1); | |
measureSync(syncFn, 1, 3); | |
measureSync(syncFn, 1, 3, "hello"); | |
measureSync(syncFn, 1, 3, "hello", boolean); |
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
gcloud run services add-iam-policy-binding SERVICE_NAME \ | |
--member=user:EMAIL \ | |
--role=roles/run.invoker |
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
# Login | |
# Browser is being opened for login | |
glcoud auth login | |
# Generate Bearer Token | |
gcloud auth print-identity-token |
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
// Numbers | |
(() => { | |
let a = 5; | |
let b = a; | |
a = 6; | |
console.log(`-- Number --`); | |
console.log(`a: ${a}`); // a: 6 | |
console.log(`b: ${b}`); // b: 5 | |
console.log(`\n`); |
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
// Objects | |
(() => { | |
let a = { content: 'a' }; | |
let b = a; | |
a.content = 'something else'; | |
console.log(`-- Object --`); | |
console.log(`a: ${JSON.stringify(a)}`); // a: {"content":"something else"} | |
console.log(`b: ${JSON.stringify(b)}`); // b: {"content":"something else"} | |
console.log(`\n`); |