Skip to content

Instantly share code, notes, and snippets.

@matheuss
matheuss / benchmark.js
Last active January 2, 2023 21:30
Poor-man's, dependency-less benchmarking util
// returns time in microseconds. Date.now() is only milli
function now() {
const hrTime = process.hrtime();
// use this for nanosecond
// return hrTime[0] * 1000000000 + hrTime[1];
return hrTime[0] * 1000000 + hrTime[1] / 1000;
}
function median(numbers) {
const sorted = Array.from(numbers).sort((a, b) => a - b);

Keybase proof

I hereby claim:

  • I am matheuss on github.
  • I am matheus (https://keybase.io/matheus) on keybase.
  • I have a public key ASDnFsuzZDaVNzih-aSY_ejFrOjhHA0Io1n6caFW1g_LIwo

To claim this, I am signing this object:

#!/usr/bin/env bash
# APP_DIR="./test"
APP_DIR="/srv/production/tomcat/webapps/ROOT"
function dir_not_supplied {
echo "Directory not supplied: assuming '.'"
BACKUP_DIR="./backup-folders"
}
do
{
flush();
cin >> code;
}
while(!searchByCode(products, code));
#include <iostream>
using namespace std;
#if defined __unix__
#define os 1
#elif defined _WIN32
#define os 2
#elif defined __APPLE__
#define os 3
#include <stdio.h>
#if defined __unix__
#define os 1
#elif defined _WIN32
#define os 2
#endif
int main()
#include <iostream>
using namespace std;
#if defined __unix__
#define os 1
#elif defined _WIN32
#define os 2
#endif
void addProduct(Product* products[])
{
int static count = 1;
string description, unity;
int option = 1, quantity;
float sellPrice, purchasePrice;
do
{
cout << "Entre com o preço de compra do produto:\n";