Skip to content

Instantly share code, notes, and snippets.

@ibsusu
ibsusu / benchmark.js
Last active November 14, 2022 10:45
arraybuffer back objects with webworker sorting
/// benchmark.js
async function benchmark() {
let namePromises = [];
let namePromises2 = [];
for (let i=0;i<100000;++i){
namePromises.push(utils.getRandomName()); // you'll need to make your own
namePromises2.push(utils.getRandomName()); // same here
}
let names = await Promise.all(namePromises);
@ibsusu
ibsusu / buffer-backed-objects_with_sorting.js
Created August 2, 2021 21:07
Sorting works with buffer backed objects. This is probably not the fastest or most complete implementation.
/**
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@ibsusu
ibsusu / buffer-backed-objects.js
Created August 2, 2021 19:45
Working implementation of direct assignment
/**
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@ibsusu
ibsusu / HelloWorld.cpp
Created April 9, 2020 05:45
Wrk Hello world benchmark of nim websockets and uWebSockets
#include "App.h"
int main() {
/* Overly simple hello world app */
uWS::App().get("/*", [](auto *res, auto *req) {
res->end("Hello world!");
}).listen(3000, [](auto *token) {
if (token) {
std::cout << "Listening on port " << 3000 << std::endl;
}