Skip to content

Instantly share code, notes, and snippets.

Avatar

Valentin Deleplace Deleplace

View GitHub Profile
@Deleplace
Deleplace / mapfunc_test.go
Created November 17, 2022 13:01
Is there a performance penalty when taking a func argument instead of a value argument, in concurrent maps operations?
View mapfunc_test.go
package mapfunc
import (
"sync"
"testing"
"github.com/puzpuzpuz/xsync/v2"
)
const (
@Deleplace
Deleplace / gist:869094a77a5292b40511704482e3e7d8
Created November 9, 2022 10:07
URL for Google Images search, to be used in Chrome in Settings > Search engine > Add
View gist:869094a77a5292b40511704482e3e7d8
https://www.google.com/search?q=%s&tbm=isch
@Deleplace
Deleplace / stablesort_test.go
Last active November 7, 2022 16:32
Overhead of stable sorting, in Go
View stablesort_test.go
package stablesort
import (
"math/rand"
"sort"
"testing"
"golang.org/x/exp/slices"
)
@Deleplace
Deleplace / stablesort_test.go
Created November 7, 2022 15:30
How much overhead for a STABLE sort of 1000 lowercase letters (26 possible values per letter), compared to a standard sort?
View stablesort_test.go
package stablesort
import (
"math/rand"
"sort"
"testing"
)
const (
M = 500
@Deleplace
Deleplace / roses-are-red.txt
Created September 15, 2022 09:50
Roses Are Red
View roses-are-red.txt
Roses are red
Violets are blue,
Sugar is sweet
And so are you.
@Deleplace
Deleplace / othello.txt
Created September 15, 2022 09:43
Othello
View othello.txt
Othello, the Moore of Venice
ACT I
SCENE I. Venice. A street.
Enter RODERIGO and IAGO
RODERIGO
Tush! never tell me; I take it much unkindly
That thou, Iago, who hast had my purse
As if the strings were thine, shouldst know of this.
IAGO
@Deleplace
Deleplace / hamlet.txt
Created September 15, 2022 09:41
Hamlet
View hamlet.txt
The Tragedy of Hamlet, Prince of Denmark
ACT I
SCENE I. Elsinore. A platform before the castle.
FRANCISCO at his post. Enter to him BERNARDO
BERNARDO
Who's there?
FRANCISCO
Nay, answer me: stand, and unfold yourself.
BERNARDO
@Deleplace
Deleplace / set_implementations.go
Last active September 9, 2022 16:41
Comparison of memory footprint of map[int]bool vs. map[int]struct{}
View set_implementations.go
package main
import (
"fmt"
"math/rand"
"runtime"
)
func main() {
BoolImplMemoryFootprint()
@Deleplace
Deleplace / insert_test.go
Created September 8, 2022 12:51
Benchmark heavy use of slices.Insert vs. heavy use of a dynamic-array-like insert func
View insert_test.go
package insert
import (
"fmt"
"testing"
"golang.org/x/exp/slices"
)
func BenchmarkGrow(b *testing.B) {