Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Learning Rust

Teiva Harsanyi teivah

🦀
Learning Rust
View GitHub Profile
View bench.go
const size = 512
var result int64
func Benchmark8Size(b *testing.B) {
const arraySize = 8
s := make([][arraySize]int64, size)
var r int64
b.ResetTimer()
View BenchmarkStructurePaddingStruct.go
type PaddedStruct struct {
n int
_ CacheLinePad
}
type CacheLinePad struct {
_ [CacheLinePadSize]byte
}
const CacheLinePadSize = 64
View BenchmarkStructurePadding.go
func BenchmarkStructurePadding(b *testing.B) {
structA := PaddedStruct{}
structB := SimpleStruct{}
wg := sync.WaitGroup{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
wg.Add(2)
go func() {
for j := 0; j < M; j++ {
View BenchmarkStructureFalseSharing.go
type SimpleStruct struct {
n int
}
func BenchmarkStructureFalseSharing(b *testing.B) {
structA := SimpleStruct{}
structB := SimpleStruct{}
wg := sync.WaitGroup{}
b.ResetTimer()
View BenchmarkMatrixReversedCombinationPerBlock.go
func BenchmarkMatrixReversedCombinationPerBlock(b *testing.B) {
matrixA := createMatrix(matrixLength)
matrixB := createMatrix(matrixLength)
blockSize := 8
for n := 0; n < b.N; n++ {
for i := 0; i < matrixLength; i += blockSize {
for j := 0; j < matrixLength; j += blockSize {
for ii := i; ii < i+blockSize; ii++ {
for jj := j; jj < j+blockSize; jj++ {
View BenchmarkMatrixReversedCombination.go
func BenchmarkMatrixReversedCombination(b *testing.B) {
matrixA := createMatrix(matrixLength)
matrixB := createMatrix(matrixLength)
for n := 0; n < b.N; n++ {
for i := 0; i < matrixLength; i++ {
for j := 0; j < matrixLength; j++ {
matrixA[i][j] = matrixA[i][j] + matrixB[j][i]
}
}
View BenchmarkMatrixCombination.go
func BenchmarkMatrixCombination(b *testing.B) {
matrixA := createMatrix(matrixLength)
matrixB := createMatrix(matrixLength)
for n := 0; n < b.N; n++ {
for i := 0; i < matrixLength; i++ {
for j := 0; j < matrixLength; j++ {
matrixA[i][j] = matrixA[i][j] + matrixB[i][j]
}
}
View rendezvous.go
type RendezVous struct {
nodes []Node
}
type Node struct {
id string
}
func (r *RendezVous) Get(key string) (*Node, error) {
length := uint32(len(r.nodes))
View jump_hash.cpp
int32_t JumpConsistentHash(uint64_t key, int32_t num_buckets) {
int64_t b = ­1, j = 0;
while (j < num_buckets) {
b=j;
key = key * 2862933555777941757ULL + 1; // Did you say magic number?
j = (b + 1) * (double(1LL << 31) / double((key >> 33) + 1));
}
return b;
}
View connect.go
ch := make(chan rxgo.Item)
go func() {
ch <- rxgo.Of(1)
ch <- rxgo.Of(2)
ch <- rxgo.Of(3)
close(ch)
}()
source := rxgo.FromChannel(ch, rxgo.WithPublishStrategy())
You can’t perform that action at this time.