{{ . }}
{{ end }} + {{ with .Content }}-
+ {{ range .Paginator.Pages }}
+
-
+ + {{ if eq $listtitle "Posts" }} + {{ .Date.Format "2006-01-02" }} {{.Title }} + {{ else }} + {{.Title }} + {{ end }} ++
+ {{ end }}
+
diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml new file mode 100644 index 0000000..3a36d14 --- /dev/null +++ b/.github/workflows/website.yml @@ -0,0 +1,41 @@ +name: research +on: + push: + branches: [ master ] +jobs: + + build: + name: research + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.15 + uses: actions/setup-go@v1 + with: + go-version: 1.15 + id: go + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: '0.60.1' + extended: true + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Build Research Website + env: + USER: ${{ secrets.SERVER_USER }} + TARGET: ${{ secrets.SERVER_PATH }} + KEY: ${{ secrets.SERVER_KEY }} + DOMAIN: ${{ secrets.SERVER_DOMAIN }} + run: | + make + mkdir ~/.ssh + echo "$KEY" | tr -d '\r' > ~/.ssh/idkey + chmod 400 ~/.ssh/idkey + eval "$(ssh-agent -s)" + ssh-add ~/.ssh/idkey + ssh-keyscan -H $DOMAIN >> ~/.ssh/known_hosts + scp -r public/* $USER@$DOMAIN:$TARGET \ No newline at end of file diff --git a/.gitignore b/.gitignore index 66fd13c..1191ab0 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ # Dependency directories (remove the comment below to include it) # vendor/ +resources +public +.DS_Store diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e240b2d --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ + License + ------- + + Copyright (c) 2020 The golang.design Initiative + All Rights Reserved + +Unauthorized using, copying, modifying and distributing, via any medium +is strictly prohibited. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e27e58e --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +all: + hugo +s: + hugo server diff --git a/README.md b/README.md index 5cdf0c7..750d535 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,8 @@ # research -(Possibly) Naïve thoughts regarding Go. - -## Table of Content +https://golang.design/research -- [Changkun Ou. Pointers Might Not Be Ideal for Parameters. Oct 27, 2020.](./pointer-params.md) -- [Changkun Ou. Eliminating A Source of Measurement Errors in Benchmarks. Sep 30, 2020.](./bench-time.md) +(Possibly) Naïve thoughts regarding Go. ## License diff --git a/archetypes/default.md b/archetypes/default.md new file mode 100644 index 0000000..ccfe607 --- /dev/null +++ b/archetypes/default.md @@ -0,0 +1,9 @@ +--- +date: {{ now.Format "2006-01-02T15:04:05Z07:00" }} +toc: true +slug: /{{ .Name }} +tags: + - Go +title: {{ .Name }} +draft: true +--- \ No newline at end of file diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..5180935 --- /dev/null +++ b/config.toml @@ -0,0 +1,39 @@ +baseURL = "https://golang.design/research" +languageCode = "en-us" +title = "golang.design/research" +theme = "research" +[permalinks] + posts = "/:slug" + +[params] + subtitle = "(Possibly) Naïve thoughts regarding Go." + dateFmt = "02.01.2006" + +[menu] + [[menu.main]] + identifier = "posts" + name = "Posts" + url = "/posts/" + weight = 1 + [[menu.main]] + identifier = "tags" + name = "Tags" + url = "/tags/" + weight = 2 + [[menu.footer]] + name = "GitHub" + url = "https://github.com/golang-design/research" + weight = 1 +[markup] + [markup.highlight] + anchorLineNos = false + codeFences = true + guessSyntax = true + hl_Lines = "" + lineAnchors = "" + lineNoStart = 1 + lineNos = true + lineNumbersInTable = false + noClasses = true + style = "native" + tabWidth = 4 \ No newline at end of file diff --git a/bench-time/bench_test.go b/content/assets/bench-time/bench_test.go similarity index 100% rename from bench-time/bench_test.go rename to content/assets/bench-time/bench_test.go diff --git a/bench-time/cpp/main.cpp b/content/assets/bench-time/cpp/main.cpp similarity index 100% rename from bench-time/cpp/main.cpp rename to content/assets/bench-time/cpp/main.cpp diff --git a/bench-time/cpp/solution.cpp b/content/assets/bench-time/cpp/solution.cpp similarity index 100% rename from bench-time/cpp/solution.cpp rename to content/assets/bench-time/cpp/solution.cpp diff --git a/bench-time/flow.png b/content/assets/bench-time/flow.png similarity index 100% rename from bench-time/flow.png rename to content/assets/bench-time/flow.png diff --git a/bench-time/go.mod b/content/assets/bench-time/go.mod similarity index 100% rename from bench-time/go.mod rename to content/assets/bench-time/go.mod diff --git a/bench-time/pprof1.png b/content/assets/bench-time/pprof1.png similarity index 100% rename from bench-time/pprof1.png rename to content/assets/bench-time/pprof1.png diff --git a/bench-time/pprof2.png b/content/assets/bench-time/pprof2.png similarity index 100% rename from bench-time/pprof2.png rename to content/assets/bench-time/pprof2.png diff --git a/bench-time/raw.graffle b/content/assets/bench-time/raw.graffle similarity index 100% rename from bench-time/raw.graffle rename to content/assets/bench-time/raw.graffle diff --git a/pointer-params/Makefile b/content/assets/pointer-params/Makefile similarity index 100% rename from pointer-params/Makefile rename to content/assets/pointer-params/Makefile diff --git a/pointer-params/asm/vec.s b/content/assets/pointer-params/asm/vec.s similarity index 100% rename from pointer-params/asm/vec.s rename to content/assets/pointer-params/asm/vec.s diff --git a/pointer-params/fields/Makefile b/content/assets/pointer-params/fields/Makefile similarity index 100% rename from pointer-params/fields/Makefile rename to content/assets/pointer-params/fields/Makefile diff --git a/pointer-params/fields/benchstat.txt b/content/assets/pointer-params/fields/benchstat.txt similarity index 100% rename from pointer-params/fields/benchstat.txt rename to content/assets/pointer-params/fields/benchstat.txt diff --git a/pointer-params/fields/fields.go b/content/assets/pointer-params/fields/fields.go similarity index 100% rename from pointer-params/fields/fields.go rename to content/assets/pointer-params/fields/fields.go diff --git a/pointer-params/fields/gen.go b/content/assets/pointer-params/fields/gen.go similarity index 100% rename from pointer-params/fields/gen.go rename to content/assets/pointer-params/fields/gen.go diff --git a/pointer-params/fields/impl_test.go b/content/assets/pointer-params/fields/impl_test.go similarity index 100% rename from pointer-params/fields/impl_test.go rename to content/assets/pointer-params/fields/impl_test.go diff --git a/pointer-params/fields/inline.txt b/content/assets/pointer-params/fields/inline.txt similarity index 100% rename from pointer-params/fields/inline.txt rename to content/assets/pointer-params/fields/inline.txt diff --git a/pointer-params/fields/noinline.txt b/content/assets/pointer-params/fields/noinline.txt similarity index 100% rename from pointer-params/fields/noinline.txt rename to content/assets/pointer-params/fields/noinline.txt diff --git a/pointer-params/go.mod b/content/assets/pointer-params/go.mod similarity index 100% rename from pointer-params/go.mod rename to content/assets/pointer-params/go.mod diff --git a/pointer-params/new.txt b/content/assets/pointer-params/new.txt similarity index 100% rename from pointer-params/new.txt rename to content/assets/pointer-params/new.txt diff --git a/pointer-params/old.txt b/content/assets/pointer-params/old.txt similarity index 100% rename from pointer-params/old.txt rename to content/assets/pointer-params/old.txt diff --git a/pointer-params/vec.go b/content/assets/pointer-params/vec.go similarity index 100% rename from pointer-params/vec.go rename to content/assets/pointer-params/vec.go diff --git a/pointer-params/vec_test.go b/content/assets/pointer-params/vec_test.go similarity index 100% rename from pointer-params/vec_test.go rename to content/assets/pointer-params/vec_test.go diff --git a/pointer-params/vis.png b/content/assets/pointer-params/vis.png similarity index 100% rename from pointer-params/vis.png rename to content/assets/pointer-params/vis.png diff --git a/bench-time.md b/content/posts/bench-time.md similarity index 97% rename from bench-time.md rename to content/posts/bench-time.md index 65ad466..6982126 100644 --- a/bench-time.md +++ b/content/posts/bench-time.md @@ -1,15 +1,24 @@ -# Eliminating A Source of Measurement Errors in Benchmarks +--- +date: 2020-09-30T09:02:20+01:00 +toc: true +slug: /bench-time +tags: + - Benchmark + - Error + - TimeMeasurement +title: Eliminating A Source of Measurement Errors in Benchmarks +--- Author(s): [Changkun Ou](https://changkun.de) -Last updated: 2020-09-30 - -## Introduction - About six months ago, I did a [presentation](https://golang.design/s/gobench) that talks about how to conduct a reliable benchmark in Go. Recently, I submitted an issue [#41641](https://golang.org/issue/41641) to the Go project, which is also a subtle issue that you might need to address in some cases. + + +## Introduction + It is all about the following code snippet: ```go @@ -141,7 +150,7 @@ go test -v -run=none -bench=WithTimer -benchtime=100000x -count=5 -cpuprofile cp Sadly, the graph shows a chunk of useless information where most of the costs shows as `runtime.ReadMemStats`: -![pprof](./bench-time/pprof1.png) +![pprof](../assets/bench-time/pprof1.png) This is because of the `StopTimer/StartTimer` implementation in the testing package calls `runtime.ReadMemStats`: @@ -203,7 +212,7 @@ func (b *B) StopTimer() { And re-run the test again, then we have: -![pprof](./bench-time/pprof2.png) +![pprof](../assets/bench-time/pprof2.png) Have you noticed where the problem is? Yes, there is a heavy cost in calling `time.Now()` in a tight loop (not really surprising because it is a system call). @@ -281,9 +290,7 @@ and you could see that the output remains end in the cost of `avg since: 16ns`. Thus, in terms of benchmarking, the actual measured time of a target code equals to the execution time of target code plus the overhead of calling `now()`: -
-
-
+ +
+ {{ end }} +