aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorhovertank3d <[email protected]>2025-01-18 23:27:52 +0100
committerhovertank3d <[email protected]>2025-01-18 23:28:53 +0100
commit1a5a86a5d4557200db20e20206bcdd7b9b2a7e55 (patch)
tree03aae452a7dc2d9f71cf7a83adbfd8e112ad562e /main.go
parent2aa29060c81fb52884b290603f1cf930259443b9 (diff)
downloadlzcnt.space-1a5a86a5d4557200db20e20206bcdd7b9b2a7e55.tar.xz
lzcnt.space-1a5a86a5d4557200db20e20206bcdd7b9b2a7e55.zip
refactor and add /about
Diffstat (limited to 'main.go')
-rw-r--r--main.go53
1 files changed, 0 insertions, 53 deletions
diff --git a/main.go b/main.go
deleted file mode 100644
index b7ae65c..0000000
--- a/main.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package main
-
-import (
- "html/template"
- "log"
- "net/http"
- "os"
- "sync/atomic"
-
- "embed"
-)
-
-/*
-#include <stdint.h>
-extern unsigned long int log2lzcnt(unsigned long int);
-*/
-import "C"
-
-//go:embed templates
-var templates embed.FS
-
-func main() {
- counter := atomic.Uint64{}
- host := ":8080"
- if len(os.Args) == 2 {
- host = os.Args[1]
- }
-
- tmpl, err := template.ParseFS(templates, "templates/*.html")
- if err != nil {
- log.Fatal(err)
- }
-
- http.HandleFunc("/reset", func(w http.ResponseWriter, r *http.Request) {
- counter.Store(0)
- http.Redirect(w, r, "/", http.StatusSeeOther)
- })
-
- http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- n := counter.Add(1)
- payload := struct {
- Requests uint64
- Log2lzcnt uint64
- }{
- Requests: n,
- Log2lzcnt: uint64(C.log2lzcnt(C.uint64_t(n))),
- }
-
- tmpl.Execute(w, payload)
- })
-
- http.ListenAndServe(host, nil)
-}