This gist implements the binary-trees
benchmark from the Language Shootout Game using the arenas GOEXPERIMENT
in Go 1.20. trees.go
is based on the Go #6 entry, but uses a manual free list instead of sync.Pool
. To enable arena support, just set GOEXPERIMENT=arenas
.
This file contains 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
module test | |
go 1.21 |
This file contains 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
diff --git a/gui-wl/wl-cb.c b/gui-wl/wl-cb.c | |
index 2e07bf8..514aaf7 100644 | |
--- a/gui-wl/wl-cb.c | |
+++ b/gui-wl/wl-cb.c | |
@@ -698,7 +698,7 @@ wlsetcb(Wlwin *wl) | |
wl_display_roundtrip(wl->display); | |
wl->xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); | |
- if(wl->shm == nil || wl->compositor == nil || wl->xdg_wm_base == nil || wl->seat == nil || wl->decoman == nil || wl->primsel == nil) | |
+ if(wl->shm == nil || wl->compositor == nil || wl->xdg_wm_base == nil || wl->seat == nil || wl->primsel == nil) |
This gist runs the binary-trees
benchmark from the Language Shootout Game as a go test
benchmark. trees.go
is copied verbatim from the Go #6 entry.
To run the benchmark, just use go test -bench='.*'
. If you would like to test PGO, which was the original intention of this code, you can use the following series of commands
$ go test -cpuprofile default.pgo -bench='.*'
$ go test -pgo auto -bench='.*'
This file contains 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
#include <u.h> | |
#include <libc.h> | |
#include <thread.h> | |
typedef struct FilterArg { | |
Channel *in; | |
Channel *out; | |
int prime; | |
} FilterArg; |
This file contains 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 ( | |
"errors" | |
"fmt" | |
"io/fs" | |
) | |
type Unwrapper[T any] interface { | |
Unwrap() T |
This file contains 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 sync | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
type Future[T any] struct { | |
done chan struct{} |
This file contains 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
module test | |
go 1.19 | |
require ( | |
github.com/charmbracelet/bubbletea v0.22.1 | |
github.com/charmbracelet/lipgloss v0.6.0 | |
golang.org/x/term v0.0.0-20220919170432-7a66f970e087 | |
) |
This file contains 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" | |
"strconv" | |
"unsafe" | |
) | |
type Event interface { | |
etype() etype |
This file contains 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
module points | |
go 1.18 |