From 8b932fb332fa533ce3b1f0ad71ce1705bb7b06af Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 20 Feb 2025 23:54:13 +0100 Subject: [PATCH] Improved documentation --- docs/readme.md | 2 +- src/asmc/Finalize.go | 13 ++++++------ tests/readme.md | 48 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/docs/readme.md b/docs/readme.md index 8716f7e..842942e 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -33,7 +33,7 @@ You can take a look at the [examples](../examples). go run gotest.tools/gotestsum@latest ``` -This will run over 350 tests in various categories. +This will run over 350 [tests](../tests) in various categories. ## Platforms diff --git a/src/asmc/Finalize.go b/src/asmc/Finalize.go index 71bb996..377b777 100644 --- a/src/asmc/Finalize.go +++ b/src/asmc/Finalize.go @@ -15,12 +15,13 @@ func Finalize(a asm.Assembler, dlls dll.List) ([]byte, []byte) { } c := compiler{ - code: make([]byte, 0, len(a.Instructions)*8), - codeLabels: make(map[string]Address, 32), - codeStart: codeOffset(), - data: data, - dataLabels: dataLabels, - dlls: dlls, + code: make([]byte, 0, len(a.Instructions)*8), + codeLabels: make(map[string]Address, 32), + codePointers: make([]*pointer, 0, len(a.Instructions)*8), + codeStart: codeOffset(), + data: data, + dataLabels: dataLabels, + dlls: dlls, } for _, x := range a.Instructions { diff --git a/tests/readme.md b/tests/readme.md index 07bcf2e..21419f9 100644 --- a/tests/readme.md +++ b/tests/readme.md @@ -1,11 +1,57 @@ ## Tests +Basic test run: + ```shell -go test ./... -v -cover +go test ./... -v +``` + +Prettier output using `gotestsum`: + +```shell +go run gotest.tools/gotestsum@latest +``` + +## Coverage + +Generate a coverage profile: + +```shell +go test -coverpkg=./... -coverprofile=cover.out ./... +``` + +View the data: + +```shell +go tool cover -func cover.out +go tool cover -html cover.out ``` ## Benchmarks +Run all benchmarks: + ```shell go test ./tests -run='^$' -bench=. -benchmem +``` + +Examples only: + +```shell +go test ./tests -run='^$' -bench=Examples/ -benchmem +``` + +## Profiling + +Generate a profile: + +```shell +go test ./tests -run='^$' -bench=Examples/ -benchmem -cpuprofile cpu.out -memprofile mem.out +``` + +View the data: + +```shell +go tool pprof --nodefraction=0.1 -http=:8080 ./cpu.out +go tool pprof --nodefraction=0.1 -http=:8080 ./mem.out ``` \ No newline at end of file