Skip to content

Instantly share code, notes, and snippets.

View Mytherin's full-sized avatar

Mark Mytherin

View GitHub Profile
CREATE TABLE integers(i INTEGER);
INSERT INTO integers VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO integers SELECT * FROM integers;
INSERT INTO integers SELECT * FROM integers;
INSERT INTO integers SELECT * FROM integers;
INSERT INTO integers SELECT * FROM integers;
INSERT INTO integers SELECT * FROM integers;
INSERT INTO integers SELECT * FROM integers;
INSERT INTO integers SELECT * FROM integers;
INSERT INTO integers SELECT * FROM integers;
---------
|| Q01 ||
---------
Cold run...DONE
1/5...0.410917
2/5...0.415055
3/5...0.407873
4/5...0.411738
5/5...0.409701
---------
// First missing positive
// Array of integers (negative or positive)
// [1, -3, 2, -4, 3, -5]
// O(n) time
// O(n) space
@Mytherin
Mytherin / benchlist.cpp
Created October 14, 2020 20:31
Benchmark of insertion performance of std::list vs std::vector
#include <list>
#include <vector>
#include <chrono>
#include <iostream>
using namespace std;
// compile: clang++ -std=c++11 -O3 benchlist.cpp
// List duration: 809ms
// Vector duration: 147ms
#include <chrono>
#include <iostream>
#include <stdlib.h>
#include <bitset>
#include <vector>
// #include "x86/avx.h"
// #include "x86/avx512f.h"
@Mytherin
Mytherin / test-64.cpp
Created September 30, 2020 21:43
Bitmask vs selection vector, int64
#include <chrono>
#include <iostream>
#include <stdlib.h>
#include <bitset>
#include <vector>
// #include "x86/avx.h"
// #include "x86/avx512f.h"
@Mytherin
Mytherin / test.cpp
Last active October 1, 2020 07:43
AVX512 Bitmask vs scalar selection vector
#include <chrono>
#include <iostream>
#include <stdlib.h>
#include <bitset>
#include <vector>
// #include "x86/avx.h"
// #include "x86/avx512f.h"
@Mytherin
Mytherin / template.cpp
Created June 8, 2020 15:33
Variadic templates to find types
#include <string>
#include <vector>
#include <iostream>
#include <type_traits>
using namespace std;
template<typename T>
string GetArgumentType() {
if (std::is_same<T, int>()) {
@Mytherin
Mytherin / jemalloc.py
Created May 8, 2020 15:16
Format Benchmarks as Markdown Table
import numpy
benchmarks = {}
def flush_benchmark(fname, benchmark, times):
if benchmark == None:
return
benchmarks[fname][benchmark] = numpy.mean(times)
import duckdb
import numpy as np
import pandas as pd
import time
lineitem = pd.read_csv('duckdb_benchmark_data/tpch_lineitem.csv', names=["l_orderkey","l_partkey","l_suppkey","l_linenumber","l_quantity","l_extendedprice","l_discount","l_tax","l_returnflag","l_linestatus","l_shipdate","l_commitdate","l_receiptdate","l_shipinstruct","l_shipmode","l_comment"], parse_dates=['l_shipdate', 'l_commitdate', 'l_receiptdate'])
def udf_disc_price(extended, discount):
return np.multiply(extended, np.subtract(1, discount))