Skip to content

Instantly share code, notes, and snippets.

View GoldsteinE's full-sized avatar

Max “Goldstein” Siling GoldsteinE

View GitHub Profile
newtype State s a = State { runState :: s -> (a, s) }
instance Monad (State s) where
(State x) >>= f = State $ \s ->
let (a, s') = x s
(State x') = f a
in x' s'
instance Applicative (State s) where
pure x = State $ \s -> (x, s)
newtype Writer w a = Writer { runWriter :: (a, w) }
instance Functor (Writer w) where
fmap f x = let (Writer (a, w)) = x in Writer (f a, w)
instance (Monoid w) => Applicative (Writer w) where
pure x = Writer (x, mempty)
Writer (f, w2) <*> Writer (x, w1) = Writer (f x, w1 `mappend` w2)
instance (Monoid w) => Monad (Writer w) where
#include <stdio.h>
#include <sys/mman.h>
int main() {
printf("mmaping zero\n");
int* pa = mmap(0, sizeof(int), PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0);
if (pa == MAP_FAILED) {
perror("mmap failed: ");
return 1;
}
HEAD is now at b97cc36 fixup! Refactor Storage so operations can fail
With #[derive(Hash)]:
Pre-heating...
Iteration #1:
Debug:
real 0m6.437s
user 0m6.089s
sys 0m0.491s
Release:
HEAD is now at b97cc36 fixup! Refactor Storage so operations can fail
With #[derive(Hash)]:
Pre-heating...
Iteration #1:
Debug:
Release:
Iteration #2:
Debug:
Release:
#!/bin/sh
preheat() {
echo "Pre-heating..."
cargo build >/dev/null 2>&1
cargo build --release >/dev/null 2>&1
}
run_benchmark() {
for i in $(seq 1 5); do
#!/bin/sh
preheat() {
echo "Pre-heating..."
cargo build >/dev/null 2>&1
cargo build --release >/dev/null 2>&1
}
run_benchmark() {
for i in $(seq 1 5); do
#!/bin/sh
preheat() {
echo "Pre-heating..."
cargo build >/dev/null 2>&1
cargo build --release >/dev/null 2>&1
}
run_benchmark() {
for i in $(seq 1 5); do
+-----------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| Item | Self time | % of total time | Time | Item count | Cache hits | Blocked time | Incremental load time |
+-----------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| LLVM_module_codegen_emit_obj | 15.12s | 32.756 | 15.12s | 461 | 0 | 0.00ns | 0.00ns |
+-----------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| codegen_module | 5.32s | 11.526 | 5.70s | 461 | 0 | 0.00ns | 0.00ns |
+-----------------------------------------------+-----------+-----------------+---------
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| Item | Self time | % of total time | Time | Item count | Cache hits | Blocked time | Incremental load time |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| LLVM_module_optimize_module_passes | 36.70s | 25.719 | 36.70s | 16 | 0 | 0.00ns | 0.00ns |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| LLVM_thin_lto_optimize | 31.21s | 21.869 | 31.21s | 16 | 0 | 0.00ns | 0.00ns |
+---------------------------------------------+-----------+-----------------+----------+------------