This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package localcache | |
import "context" | |
type Cache[K comparable, T any] interface { | |
MGet(ctx context.Context, ids []K) ([]T, error) | |
} | |
type Storage[K comparable, T any] interface { | |
Load(ctx context.Context, ids []K) (map[K][]byte, error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils | |
import "testing" | |
// BenchmarkSliceCopy 对比 slice 通过 loop 和 copy 进行复制的性能 | |
func BenchmarkSliceCopy(b *testing.B) { | |
const length = 256 | |
type foo struct { | |
val int | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
goos: darwin | |
goarch: amd64 | |
pkg: perf | |
BenchmarkBulk | |
BenchmarkBulk/re | |
BenchmarkBulk/re-4 15252195 67.9 ns/op 48 B/op 1 allocs/op | |
BenchmarkBulk/slow | |
BenchmarkBulk/slow-4 224365 5269 ns/op 12352 B/op 29 allocs/op | |
PASS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
goos: darwin | |
goarch: amd64 | |
pkg: perf | |
BenchmarkMapAssign | |
BenchmarkMapAssign/struct{} | |
BenchmarkMapAssign/struct{}-4 342277 3384 ns/op 1658 B/op 7 allocs/op | |
BenchmarkMapAssign/struct{}#01 | |
BenchmarkMapAssign/struct{}#01-4 176937 6258 ns/op 3071 B/op 17 allocs/op | |
BenchmarkMapAssign/bool | |
BenchmarkMapAssign/bool-4 377792 3118 ns/op 3109 B/op 2 allocs/op |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BenchmarkSubStr/split | |
BenchmarkSubStr/split-4 11353098 106 ns/op 32 B/op 1 allocs/op | |
BenchmarkSubStr/index | |
BenchmarkSubStr/index-4 187964112 6.37 ns/op 0 B/op 0 allocs/op |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func BenchmarkFormat(b *testing.B) { | |
b.Run("appendFormat", func(b *testing.B) { | |
b.ReportAllocs() | |
var specIdStr []byte | |
var l int = 10 | |
for i := 0; i < b.N; i++ { | |
val1 := rand.Int63() | |
val2 := rand.Int63() | |
val3 := rand.Int63() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash --login | |
REMOTE_PROJECT_PATH=$1 | |
REMOTE_GO_PATH=$2 | |
SVC_NAME=$3 | |
PORT=$4 | |
EXEC_FILE=${REMOTE_PROJECT_PATH}/output/${SVC_NAME} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ciphers | |
import ( | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/sha1" | |
"crypto/x509" | |
"encoding/base64" | |
"testing" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
//case 1 | |
a := []int{} | |
a = append(a, 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
"unsafe" | |
) | |
func main() { | |
s := make([]int, 10, 20) |
NewerOlder