Skip to content

Instantly share code, notes, and snippets.

View itsbth's full-sized avatar

Bjørn Tore Håvie itsbth

View GitHub Profile
@itsbth
itsbth / index.html
Last active April 23, 2020 09:46
Loop-the-loop #jsbench #jsperf (https://jsbench.github.io/#0ff154d786daf3a3b62be3069089a12b) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Loop-the-loop #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
const std = @import("std");
const assert = std.debug.assert;
const mem = std.mem;
pub const Token = struct {
id: Id,
start: usize,
end: usize,
pub const Keyword = struct {
~/Scratch/tw-short master*
❯ wrk -s post.lua http://short.itsbth.com/
Running 10s test @ http://short.itsbth.com/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 32.53ms 19.13ms 261.01ms 96.67%
Req/Sec 160.37 29.53 202.00 74.00%
3199 requests in 10.01s, 817.30KB read
Requests/sec: 319.59
Transfer/sec: 81.65KB
@itsbth
itsbth / index.html
Last active November 17, 2017 11:17
Bound method showdown (https://jsbench.github.io/#c60c14e1768ebfdad0e2464016b8caa7) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Bound method showdown</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = undefined;
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
@itsbth
itsbth / solution.py
Last active December 10, 2015 22:51
#!/usr/bin/python3
import logging
def rle(iterable):
_next = next
it = iter(iterable)
value, count = None, 0
try:
while True:
item = _next(it)
from __future__ import print_function
# def is_palindrome(n):
# s = str(n)
# return s == s[::-1]
# mv = 0
# for i in range(999, 100, -1):
# for j in range(999, 100, -1):
# m = i * j
from __future__ import print_function
# def is_palindrome(n):
# s = str(n)
# return s == s[::-1]
# mv = 0
# for i in range(999, 100, -1):
# for j in range(999, 100, -1):
# m = i * j
This file has been truncated, but you can view the full file.
{"L": {"i": {"d": {"i": {"a": {"'": {"s": {}}}}}, "b": {"e": {"r": {"i": {"a": {"'": {"s": {}}, "n": {"'": {"s": {}}, "s": {}}}}, "a": {"c": {"e": {"'": {"s": {}}}}}}}, "b": {"y": {}}, "y": {"a": {"'": {"s": {}}, "n": {"'": {"s": {}}, "s": {}}}}, "r": {"i": {"u": {"m": {"'": {"s": {}}}}}, "a": {"'": {"s": {}}, "s": {}}, "e": {"v": {"i": {"l": {"l": {"e": {"'": {"s": {}}}}}}}}}}, "t": {"h": {"u": {"a": {"n": {"i": {"a": {"'": {"s": {}}, "n": {"'": {"s": {}}, "s": {}}}}}}}}, "t": {"o": {"n": {"'": {"s": {}}}}, "l": {"e": {"'": {"s": {}}}}}}, "m": {"o": {"u": {"s": {"i": {"n": {"'": {"s": {}}}}}}, "g": {"e": {"s": {}}}}, "a": {"'": {"s": {}}}, "b": {"a": {"u": {"g": {"h": {"'": {"s": {}}}}}}, "u": {"r": {"g": {"e": {"r": {}}}}}}, "p": {"o": {"p": {"o": {"'": {"s": {}}}}}}}, "e": {"g": {"e": {"'": {"s": {}}}}, "b": {"f": {"r": {"a": {"u": {"m": {"i": {"l": {"c": {"h": {}}}}}}}}}, "e": {"r": {"m": {"a": {"n": {"'": {"s": {}}}}}}}}, "c": {"h": {"t": {"e": {"n": {"s": {"t": {"e": {"i": {"n": {"'": {"s": {}}}}}}}}}}}
import sys
import pickle
from collections import defaultdict
def tree():
return defaultdict(tree)
class Trie(object):