Skip to content

Instantly share code, notes, and snippets.

View JulianKnodt's full-sized avatar
🤺

Julian Knodt JulianKnodt

🤺
View GitHub Profile
const exjson = require('./index.js');
const test = require('./test.json');
const process = require('process');
[exjson.stringify, JSON.stringify].forEach(f => {
let time = process.hrtime();
let length = f(test2).length;
let diff = process.hrtime(time);
console.log(diff[0], 'seconds', diff[1], 'nanoseconds')
console.log(length);
@JulianKnodt
JulianKnodt / uniques.js
Last active July 8, 2018 06:11 — forked from kapv89/uniques.js
Perf test on various methods to extract unique elements out of an array of objects
const f = require('faker');
let dup = (a) => a.map((el) => Object.assign({}, el));
// https://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array
const shuffle = (a) => {
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
@JulianKnodt
JulianKnodt / lib.rs
Last active December 8, 2018 23:03
Basic simd instructions in rust
#[cfg(test)]
mod tests {
use average;
#[test]
fn test_average() {
let items = vec!(3.0, 4.0, 5.0);
unsafe {
assert_eq!(average::average(&items), 4.0);
}
@JulianKnodt
JulianKnodt / pre-commit
Created March 23, 2023 06:21
pre-commit hook for linting only modified lines of cpp files with clang-format
#!/usr/bin/python3
# Author: julianknodt
# -- Description
# A git pre-commit hook that will run clang-format on only modified lines.
import subprocess
import os