Skip to content

Instantly share code, notes, and snippets.

class TransactionIndexViewTests(TestCase):
fixtures = ['transactions.json']
def test_fixture(self):
self.assertEqual(len(Transaction.objects.all()), 2)
@hnd4r7
hnd4r7 / latency.markdown
Created August 14, 2022 15:11 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@hnd4r7
hnd4r7 / deref.go
Created June 14, 2022 04:06 — forked from bokwoon95/deref.go
Go Generics type signature for ensuring argument is a pointer
// https://go.dev/play/p/oVQ0AP7_h6D
package main
import (
"fmt"
)
// Deref will dereference a generic pointer.
// It will fail at compile time if pt is not a pointer.
// +build ignore,OMIT
// realmain runs the Subscribe example with a real RSS fetcher.
package main
import (
"fmt"
"math/rand"
"time"