Skip to content

Instantly share code, notes, and snippets.

View mr-pascal's full-sized avatar

Pascal mr-pascal

View GitHub Profile
####################################
########### VARIABLES ##############
####################################
GCP_PROJECT="YOUR_PROJECT_ID"
SERVICE_NAME="my-react-app"
REGION="europe-west1"
####################################
###### GENERATED VARIABLES #########
####################################
####################################
########### VARIABLES ##############
####################################
GCP_PROJECT="YOUR_PROJECT_ID"
SERVICE_NAME="my-react-app"
REGION="europe-west1"
####################################
###### GENERATED VARIABLES #########
####################################
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;
const myMethod = () => {
const startTimeInMs = new Date().getTime();
// Do some heavy computation
// ..........
// ////////////////////////////////////////
const endTimeInMs = new Date().getTime();
const durationInMs = endTimeInMs - startTimeInMs;
/**
* 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
measureSync(syncFn, 1);
measureSync(syncFn, 1, 3);
measureSync(syncFn, 1, 3, "hello");
measureSync(syncFn, 1, 3, "hello", boolean);
gcloud run services add-iam-policy-binding SERVICE_NAME \
--member=user:EMAIL \
--role=roles/run.invoker
# Login
# Browser is being opened for login
glcoud auth login
# Generate Bearer Token
gcloud auth print-identity-token
// 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`);
// 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`);