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 Benchmark = require("benchmark"); | |
const { ObjectId } = require("bson"); | |
const _ = require("lodash"); | |
const casual = require("casual") | |
const size = 1000; | |
let array = new Array(size).fill(0).map(() => new ObjectId().toHexString()); | |
const docs = array.map((_id) => ({ | |
_id, |
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
create or replace view digits as | |
select 0 as d union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9; | |
drop table if exists nums; | |
create table nums (n int auto_increment, primary key(n)); | |
insert into nums values (), (); | |
insert into nums () select null from nums n1, nums n2, nums n3, nums n4, nums n5; | |
insert into nums () select null from nums n1, nums n2; | |
select all_nums.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
const Benchmark = require("benchmark"); | |
const { ObjectId } = require("bson"); | |
const _ = require("lodash"); | |
const size = 100; | |
let array = new Array(size).fill(0).map(() => new ObjectId().toHexString()); | |
const keyedDocs = _.keyBy(array); | |
const set = new Set(array); |
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 { AsyncLocalStorage } = require("async_hooks"); | |
const storageContext = new AsyncLocalStorage(); | |
const middlewares = []; | |
function addMiddleware(callback) { | |
middlewares.push(callback); | |
} | |
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); |
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 Benchmark = require("benchmark"); | |
const { ObjectId } = require("bson"); | |
const _ = require("lodash"); | |
const SIZES = [10, 40, 100, 1_000, 10_000, 100_000, 1_000_000]; | |
for (const isRandom of [false, true]) { | |
for (let i = 0; i < SIZES.length; i++) { | |
const size = SIZES[i]; | |
let docs = new Array(size).fill(0).map(() => new ObjectId().toHexString()); |
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 Benchmark = require("benchmark"); | |
const _ = require("lodash"); | |
const suite = new Benchmark.Suite(); | |
const TIMES = 10000; | |
suite | |
.add("pushing", function () { | |
const docs = []; | |
for (let i = 0; i < TIMES; i++) { | |
docs.push(new Date()); |
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
#!/bin/sh | |
set -eo pipefail | |
# Group ID is synonymous with projectId (in the ui) | |
GROUP_ID="" | |
# Configuration -- https://cloud.mongodb.com/v2/${GROUP_ID}/#access/apiKeys | |
# Note: the API key requires "Project owner" access in order to download the logs | |
if [ -z "$ATLAS_PUBLIC_KEY" ] || [ -z "$ATLAS_API_KEY" ]; then |