feat(search): add configurable sorting for submission results
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m17s
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m17s
Introduce a `sort` query parameter in submission search paths and pass it into store search logic. Matching results can now be ordered by `newest`, `oldest`, `score_desc`, `score_asc`, `mops_desc`, or `mops_asc`, with invalid values safely defaulting to `newest`. Update README and HTTP examples to document the new sort behavior and usage so clients can control result ordering server-side without extra post-processing.feat(search): add configurable sorting for submission results Introduce a `sort` query parameter in submission search paths and pass it into store search logic. Matching results can now be ordered by `newest`, `oldest`, `score_desc`, `score_asc`, `mops_desc`, or `mops_asc`, with invalid values safely defaulting to `newest`. Update README and HTTP examples to document the new sort behavior and usage so clients can control result ordering server-side without extra post-processing.
This commit is contained in:
11
README.md
11
README.md
@@ -5,8 +5,9 @@ Production-oriented Go web application for ingesting CPU benchmark results, stor
|
||||
## Features
|
||||
|
||||
- `POST /api/submit` accepts either `application/json` or `multipart/form-data`.
|
||||
- `GET /api/search` performs case-insensitive token matching against submitter/general fields and CPU brand strings, with explicit thread-mode, platform, intensity, and duration filters.
|
||||
- `GET /api/search` performs case-insensitive token matching against submitter/general fields and CPU brand strings, with explicit thread-mode, platform, intensity, duration, and sort controls.
|
||||
- `GET /` renders the latest submissions with search and pagination.
|
||||
- The dashboard follows the system light/dark preference by default and includes a manual theme toggle in the top-right corner.
|
||||
- BadgerDB stores each submission under a reverse-timestamp key so native iteration returns newest records first.
|
||||
- A startup-loaded in-memory search index prevents full DB deserialization for every query.
|
||||
- Graceful shutdown closes the HTTP server and BadgerDB cleanly to avoid lock issues.
|
||||
@@ -123,13 +124,14 @@ Query parameters:
|
||||
- `cpu`: token-matches `cpuInfo.brandString`
|
||||
- `thread`: `single` or `multi`
|
||||
- `platform`: `windows`, `linux`, or `macos`
|
||||
- `sort`: `newest`, `oldest`, `score_desc`, `score_asc`, `mops_desc`, or `mops_asc`
|
||||
- `intensity`: exact match on `config.intensity`
|
||||
- `durationSecs`: exact match on `config.durationSecs`
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
curl "http://localhost:8080/api/search?text=intel&cpu=13700&thread=multi&platform=windows&intensity=10&durationSecs=30"
|
||||
curl "http://localhost:8080/api/search?text=intel&cpu=13700&thread=multi&platform=windows&sort=score_desc&intensity=10&durationSecs=30"
|
||||
```
|
||||
|
||||
### `GET /`
|
||||
@@ -141,6 +143,7 @@ Query parameters:
|
||||
- `cpu`
|
||||
- `thread`
|
||||
- `platform`
|
||||
- `sort`
|
||||
- `intensity`
|
||||
- `durationSecs`
|
||||
|
||||
@@ -149,7 +152,7 @@ Examples:
|
||||
```text
|
||||
http://localhost:8080/
|
||||
http://localhost:8080/?page=2
|
||||
http://localhost:8080/?text=anonymous&cpu=ryzen&thread=multi&platform=windows&intensity=10&durationSecs=20
|
||||
http://localhost:8080/?text=anonymous&cpu=ryzen&thread=multi&platform=windows&sort=score_desc&intensity=10&durationSecs=20
|
||||
```
|
||||
|
||||
## Request Examples
|
||||
@@ -186,7 +189,7 @@ curl -X POST "http://localhost:8080/api/submit" \
|
||||
- canonical submission payload
|
||||
- normalized general search text
|
||||
- normalized CPU brand text
|
||||
- Searches scan the in-memory ordered slice rather than reopening and deserializing Badger values for every request, and apply explicit platform, thread-mode, intensity, and duration filters in memory.
|
||||
- Searches scan the in-memory ordered slice rather than reopening and deserializing Badger values for every request, apply explicit platform, thread-mode, intensity, and duration filters in memory, then optionally sort the matching results by submission time, score, or MOps/sec.
|
||||
|
||||
## Docker
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
GET http://localhost:8080/api/search?text=intel&cpu=13700&thread=multi&platform=windows&intensity=10&durationSecs=30
|
||||
GET http://localhost:8080/api/search?text=intel&cpu=13700&thread=multi&platform=windows&sort=score_desc&intensity=10&durationSecs=30
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:8080/api/search?text=anonymous&thread=single&platform=linux&intensity=1&durationSecs=10
|
||||
GET http://localhost:8080/api/search?text=anonymous&thread=single&platform=linux&sort=oldest&intensity=1&durationSecs=10
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:8080/?page=1&text=lab&cpu=ryzen&thread=multi&platform=windows&intensity=10&durationSecs=20
|
||||
GET http://localhost:8080/?page=1&text=lab&cpu=ryzen&thread=multi&platform=windows&sort=mops_desc&intensity=10&durationSecs=20
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -116,11 +117,12 @@ func (s *Store) ListSubmissions(page, pageSize int) ([]model.Submission, int) {
|
||||
return results, total
|
||||
}
|
||||
|
||||
func (s *Store) SearchSubmissions(text, cpu, thread, platform string, intensity, durationSecs int) []model.Submission {
|
||||
func (s *Store) SearchSubmissions(text, cpu, thread, platform, sortBy string, intensity, durationSecs int) []model.Submission {
|
||||
queryText := normalizeSearchText(text)
|
||||
cpuText := normalizeSearchText(cpu)
|
||||
thread = normalizeThreadFilter(thread)
|
||||
platform = normalizePlatformFilter(platform)
|
||||
sortBy = normalizeSortOption(sortBy)
|
||||
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
@@ -159,6 +161,7 @@ func (s *Store) SearchSubmissions(text, cpu, thread, platform string, intensity,
|
||||
results = append(results, *model.CloneSubmission(record.submission))
|
||||
}
|
||||
|
||||
sortSubmissions(results, sortBy)
|
||||
return results
|
||||
}
|
||||
|
||||
@@ -296,6 +299,70 @@ func normalizePlatformFilter(value string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeSortOption(value string) string {
|
||||
switch strings.ToLower(strings.TrimSpace(value)) {
|
||||
case "", "newest":
|
||||
return "newest"
|
||||
case "oldest":
|
||||
return "oldest"
|
||||
case "score_desc":
|
||||
return "score_desc"
|
||||
case "score_asc":
|
||||
return "score_asc"
|
||||
case "mops_desc":
|
||||
return "mops_desc"
|
||||
case "mops_asc":
|
||||
return "mops_asc"
|
||||
default:
|
||||
return "newest"
|
||||
}
|
||||
}
|
||||
|
||||
func sortSubmissions(submissions []model.Submission, sortBy string) {
|
||||
switch sortBy {
|
||||
case "oldest":
|
||||
sort.SliceStable(submissions, func(i, j int) bool {
|
||||
if submissions[i].SubmittedAt.Equal(submissions[j].SubmittedAt) {
|
||||
return submissions[i].SubmissionID < submissions[j].SubmissionID
|
||||
}
|
||||
|
||||
return submissions[i].SubmittedAt.Before(submissions[j].SubmittedAt)
|
||||
})
|
||||
case "score_desc":
|
||||
sort.SliceStable(submissions, func(i, j int) bool {
|
||||
if submissions[i].Score == submissions[j].Score {
|
||||
return submissions[i].SubmittedAt.After(submissions[j].SubmittedAt)
|
||||
}
|
||||
|
||||
return submissions[i].Score > submissions[j].Score
|
||||
})
|
||||
case "score_asc":
|
||||
sort.SliceStable(submissions, func(i, j int) bool {
|
||||
if submissions[i].Score == submissions[j].Score {
|
||||
return submissions[i].SubmittedAt.After(submissions[j].SubmittedAt)
|
||||
}
|
||||
|
||||
return submissions[i].Score < submissions[j].Score
|
||||
})
|
||||
case "mops_desc":
|
||||
sort.SliceStable(submissions, func(i, j int) bool {
|
||||
if submissions[i].MOpsPerSec == submissions[j].MOpsPerSec {
|
||||
return submissions[i].SubmittedAt.After(submissions[j].SubmittedAt)
|
||||
}
|
||||
|
||||
return submissions[i].MOpsPerSec > submissions[j].MOpsPerSec
|
||||
})
|
||||
case "mops_asc":
|
||||
sort.SliceStable(submissions, func(i, j int) bool {
|
||||
if submissions[i].MOpsPerSec == submissions[j].MOpsPerSec {
|
||||
return submissions[i].SubmittedAt.After(submissions[j].SubmittedAt)
|
||||
}
|
||||
|
||||
return submissions[i].MOpsPerSec < submissions[j].MOpsPerSec
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func pageBounds(page, pageSize, total int) (int, int, int) {
|
||||
if pageSize <= 0 {
|
||||
pageSize = 50
|
||||
|
||||
@@ -33,6 +33,7 @@ type indexPageData struct {
|
||||
QueryCPU string
|
||||
QueryThread string
|
||||
QueryPlatform string
|
||||
QuerySort string
|
||||
QueryIntensity int
|
||||
QueryDuration int
|
||||
Page int
|
||||
@@ -104,6 +105,7 @@ func (a *App) handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
cpu := strings.TrimSpace(r.URL.Query().Get("cpu"))
|
||||
thread := strings.TrimSpace(r.URL.Query().Get("thread"))
|
||||
platform := strings.TrimSpace(r.URL.Query().Get("platform"))
|
||||
sortBy := normalizeSortFilter(r.URL.Query().Get("sort"))
|
||||
intensity := parsePositiveInt(r.URL.Query().Get("intensity"), 0)
|
||||
durationSecs := parsePositiveInt(r.URL.Query().Get("durationSecs"), 0)
|
||||
|
||||
@@ -112,8 +114,8 @@ func (a *App) handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
totalCount int
|
||||
)
|
||||
|
||||
if text != "" || cpu != "" || thread != "" || platform != "" || intensity > 0 || durationSecs > 0 {
|
||||
matches := a.store.SearchSubmissions(text, cpu, thread, platform, intensity, durationSecs)
|
||||
if text != "" || cpu != "" || thread != "" || platform != "" || intensity > 0 || durationSecs > 0 || sortBy != "newest" {
|
||||
matches := a.store.SearchSubmissions(text, cpu, thread, platform, sortBy, intensity, durationSecs)
|
||||
totalCount = len(matches)
|
||||
start, end, normalizedPage := pageBounds(page, a.pageSize, totalCount)
|
||||
page = normalizedPage
|
||||
@@ -134,6 +136,7 @@ func (a *App) handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
QueryCPU: cpu,
|
||||
QueryThread: normalizeThreadFilter(thread),
|
||||
QueryPlatform: normalizePlatformFilter(platform),
|
||||
QuerySort: sortBy,
|
||||
QueryIntensity: intensity,
|
||||
QueryDuration: durationSecs,
|
||||
Page: page,
|
||||
@@ -141,8 +144,8 @@ func (a *App) handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
TotalCount: totalCount,
|
||||
ShowingFrom: showingFrom,
|
||||
ShowingTo: showingTo,
|
||||
PrevURL: buildIndexURL(max(1, page-1), text, cpu, thread, platform, intensity, durationSecs),
|
||||
NextURL: buildIndexURL(max(1, min(totalPageCount, page+1)), text, cpu, thread, platform, intensity, durationSecs),
|
||||
PrevURL: buildIndexURL(max(1, page-1), text, cpu, thread, platform, sortBy, intensity, durationSecs),
|
||||
NextURL: buildIndexURL(max(1, min(totalPageCount, page+1)), text, cpu, thread, platform, sortBy, intensity, durationSecs),
|
||||
}
|
||||
|
||||
if err := a.templates.ExecuteTemplate(w, "index.html", data); err != nil {
|
||||
@@ -163,6 +166,7 @@ func (a *App) handleSearch(w http.ResponseWriter, r *http.Request) {
|
||||
r.URL.Query().Get("cpu"),
|
||||
r.URL.Query().Get("thread"),
|
||||
r.URL.Query().Get("platform"),
|
||||
r.URL.Query().Get("sort"),
|
||||
parsePositiveInt(r.URL.Query().Get("intensity"), 0),
|
||||
parsePositiveInt(r.URL.Query().Get("durationSecs"), 0),
|
||||
)
|
||||
@@ -359,7 +363,7 @@ func visibleBounds(page, pageSize, visibleCount, total int) (int, int) {
|
||||
return from, to
|
||||
}
|
||||
|
||||
func buildIndexURL(page int, text, cpu, thread, platform string, intensity, durationSecs int) string {
|
||||
func buildIndexURL(page int, text, cpu, thread, platform, sortBy string, intensity, durationSecs int) string {
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
@@ -378,6 +382,9 @@ func buildIndexURL(page int, text, cpu, thread, platform string, intensity, dura
|
||||
if normalizedPlatform := normalizePlatformFilter(platform); normalizedPlatform != "" {
|
||||
values.Set("platform", normalizedPlatform)
|
||||
}
|
||||
if normalizedSort := normalizeSortFilter(sortBy); normalizedSort != "newest" {
|
||||
values.Set("sort", normalizedSort)
|
||||
}
|
||||
if intensity > 0 {
|
||||
values.Set("intensity", strconv.Itoa(intensity))
|
||||
}
|
||||
@@ -430,6 +437,25 @@ func normalizePlatformFilter(value string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeSortFilter(value string) string {
|
||||
switch strings.ToLower(strings.TrimSpace(value)) {
|
||||
case "", "newest":
|
||||
return "newest"
|
||||
case "oldest":
|
||||
return "oldest"
|
||||
case "score_desc":
|
||||
return "score_desc"
|
||||
case "score_asc":
|
||||
return "score_asc"
|
||||
case "mops_desc":
|
||||
return "mops_desc"
|
||||
case "mops_asc":
|
||||
return "mops_asc"
|
||||
default:
|
||||
return "newest"
|
||||
}
|
||||
}
|
||||
|
||||
func formatInt64(value int64) string {
|
||||
negative := value < 0
|
||||
if negative {
|
||||
|
||||
@@ -5,11 +5,44 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>CPU Benchmark Submissions</title>
|
||||
<script src="https://cdn.tailwindcss.com?plugins=forms,typography"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: "class"
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
(function() {
|
||||
var storageKey = "cpu-benchmark-theme";
|
||||
var root = document.documentElement;
|
||||
var stored = null;
|
||||
|
||||
try {
|
||||
stored = localStorage.getItem(storageKey);
|
||||
} catch (err) {}
|
||||
|
||||
var prefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
var theme = stored === "light" || stored === "dark" ? stored : (prefersDark ? "dark" : "light");
|
||||
|
||||
root.classList.toggle("dark", theme === "dark");
|
||||
root.dataset.theme = theme;
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
<body class="min-h-screen bg-slate-100 text-slate-900">
|
||||
<div class="bg-slate-950 text-white">
|
||||
<body class="min-h-screen bg-slate-100 text-slate-900 transition-colors dark:bg-slate-950 dark:text-slate-100">
|
||||
<div class="bg-slate-950 text-white dark:bg-slate-900">
|
||||
<div class="mx-auto max-w-7xl px-6 py-10">
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<p class="text-sm uppercase tracking-[0.35em] text-cyan-300">CPU Benchmark Platform</p>
|
||||
<button
|
||||
type="button"
|
||||
id="theme-toggle"
|
||||
aria-label="Toggle theme"
|
||||
class="inline-flex items-center gap-2 rounded-full border border-white/15 bg-white/10 px-3 py-2 text-sm font-medium text-slate-100 backdrop-blur transition hover:bg-white/15"
|
||||
>
|
||||
<span id="theme-toggle-icon" aria-hidden="true">◐</span>
|
||||
<span id="theme-toggle-label">Theme</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="mt-4 flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between">
|
||||
<div class="max-w-3xl">
|
||||
<h1 class="text-4xl font-bold tracking-tight">Simple CPU Benchmark Server</h1>
|
||||
@@ -17,7 +50,7 @@
|
||||
Browse recent benchmark submissions, filter by submitter or CPU brand, and inspect per-core throughput details.
|
||||
</p>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-white/10 px-4 py-3 text-sm text-slate-200 backdrop-blur">
|
||||
<div class="rounded-2xl bg-white/10 px-4 py-3 text-sm text-slate-200 backdrop-blur dark:bg-white/5">
|
||||
<div>Total results: <span class="font-semibold text-white">{{ .TotalCount }}</span></div>
|
||||
{{ if gt .ShowingTo 0 }}
|
||||
<div>Showing {{ .ShowingFrom }} to {{ .ShowingTo }}</div>
|
||||
@@ -30,33 +63,33 @@
|
||||
</div>
|
||||
|
||||
<main class="mx-auto max-w-7xl px-6 py-8">
|
||||
<section class="-mt-12 rounded-3xl border border-slate-200 bg-white p-6 shadow-xl shadow-slate-300/30">
|
||||
<form method="get" action="/" class="grid gap-4 lg:grid-cols-[2fr_2fr_1fr_1fr_1fr_1fr_auto]">
|
||||
<section class="-mt-12 rounded-3xl border border-slate-200 bg-white p-6 shadow-xl shadow-slate-300/30 transition-colors dark:border-slate-800 dark:bg-slate-900 dark:shadow-black/20">
|
||||
<form method="get" action="/" class="grid gap-4 lg:grid-cols-[2fr_2fr_1fr_1fr_1fr_1fr_1fr_auto]">
|
||||
<label class="block">
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700">General search</span>
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700 dark:text-slate-300">General search</span>
|
||||
<input
|
||||
type="text"
|
||||
name="text"
|
||||
value="{{ .QueryText }}"
|
||||
placeholder="Submitter, score, vendor, features, thread mode"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm shadow-sm focus:border-cyan-500 focus:ring-cyan-500"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm text-slate-900 shadow-sm focus:border-cyan-500 focus:ring-cyan-500 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:placeholder:text-slate-500"
|
||||
>
|
||||
</label>
|
||||
<label class="block">
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700">CPU brand</span>
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700 dark:text-slate-300">CPU brand</span>
|
||||
<input
|
||||
type="text"
|
||||
name="cpu"
|
||||
value="{{ .QueryCPU }}"
|
||||
placeholder="Ryzen 7 5800X, i7-13700K, Xeon"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm shadow-sm focus:border-cyan-500 focus:ring-cyan-500"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm text-slate-900 shadow-sm focus:border-cyan-500 focus:ring-cyan-500 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:placeholder:text-slate-500"
|
||||
>
|
||||
</label>
|
||||
<label class="block">
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700">Thread mode</span>
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700 dark:text-slate-300">Thread mode</span>
|
||||
<select
|
||||
name="thread"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm shadow-sm focus:border-cyan-500 focus:ring-cyan-500"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm text-slate-900 shadow-sm focus:border-cyan-500 focus:ring-cyan-500 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
|
||||
>
|
||||
<option value="" {{ if eq .QueryThread "" }}selected{{ end }}>All</option>
|
||||
<option value="single" {{ if eq .QueryThread "single" }}selected{{ end }}>Single-threaded</option>
|
||||
@@ -64,10 +97,10 @@
|
||||
</select>
|
||||
</label>
|
||||
<label class="block">
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700">Platform</span>
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700 dark:text-slate-300">Platform</span>
|
||||
<select
|
||||
name="platform"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm shadow-sm focus:border-cyan-500 focus:ring-cyan-500"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm text-slate-900 shadow-sm focus:border-cyan-500 focus:ring-cyan-500 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
|
||||
>
|
||||
<option value="" {{ if eq .QueryPlatform "" }}selected{{ end }}>All</option>
|
||||
<option value="windows" {{ if eq .QueryPlatform "windows" }}selected{{ end }}>Windows</option>
|
||||
@@ -76,27 +109,41 @@
|
||||
</select>
|
||||
</label>
|
||||
<label class="block">
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700">Intensity</span>
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700 dark:text-slate-300">Intensity</span>
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
name="intensity"
|
||||
value="{{ if gt .QueryIntensity 0 }}{{ .QueryIntensity }}{{ end }}"
|
||||
placeholder="10"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm shadow-sm focus:border-cyan-500 focus:ring-cyan-500"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm text-slate-900 shadow-sm focus:border-cyan-500 focus:ring-cyan-500 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:placeholder:text-slate-500"
|
||||
>
|
||||
</label>
|
||||
<label class="block">
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700">Duration (s)</span>
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700 dark:text-slate-300">Duration (s)</span>
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
name="durationSecs"
|
||||
value="{{ if gt .QueryDuration 0 }}{{ .QueryDuration }}{{ end }}"
|
||||
placeholder="20"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm shadow-sm focus:border-cyan-500 focus:ring-cyan-500"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm text-slate-900 shadow-sm focus:border-cyan-500 focus:ring-cyan-500 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:placeholder:text-slate-500"
|
||||
>
|
||||
</label>
|
||||
<label class="block">
|
||||
<span class="mb-2 block text-sm font-medium text-slate-700 dark:text-slate-300">Sort</span>
|
||||
<select
|
||||
name="sort"
|
||||
class="w-full rounded-xl border-slate-300 bg-slate-50 text-sm text-slate-900 shadow-sm focus:border-cyan-500 focus:ring-cyan-500 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100"
|
||||
>
|
||||
<option value="newest" {{ if eq .QuerySort "newest" }}selected{{ end }}>Newest first</option>
|
||||
<option value="oldest" {{ if eq .QuerySort "oldest" }}selected{{ end }}>Oldest first</option>
|
||||
<option value="score_desc" {{ if eq .QuerySort "score_desc" }}selected{{ end }}>Highest score</option>
|
||||
<option value="score_asc" {{ if eq .QuerySort "score_asc" }}selected{{ end }}>Lowest score</option>
|
||||
<option value="mops_desc" {{ if eq .QuerySort "mops_desc" }}selected{{ end }}>Highest MOps/sec</option>
|
||||
<option value="mops_asc" {{ if eq .QuerySort "mops_asc" }}selected{{ end }}>Lowest MOps/sec</option>
|
||||
</select>
|
||||
</label>
|
||||
<div class="flex gap-3 lg:justify-end">
|
||||
<button
|
||||
type="submit"
|
||||
@@ -106,7 +153,7 @@
|
||||
</button>
|
||||
<a
|
||||
href="/"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-slate-300 px-5 py-3 text-sm font-semibold text-slate-700 transition hover:bg-slate-50"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-slate-300 px-5 py-3 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
|
||||
>
|
||||
Clear
|
||||
</a>
|
||||
@@ -116,24 +163,24 @@
|
||||
|
||||
<section class="mt-8 space-y-4">
|
||||
{{ if not .Submissions }}
|
||||
<div class="rounded-2xl border border-dashed border-slate-300 bg-white px-6 py-12 text-center text-slate-500">
|
||||
<div class="rounded-2xl border border-dashed border-slate-300 bg-white px-6 py-12 text-center text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400">
|
||||
No submissions to display.
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ range .Submissions }}
|
||||
<details class="group overflow-hidden rounded-3xl border border-slate-200 bg-white shadow-sm transition hover:shadow-md">
|
||||
<details class="group overflow-hidden rounded-3xl border border-slate-200 bg-white shadow-sm transition hover:shadow-md dark:border-slate-800 dark:bg-slate-900 dark:shadow-black/20">
|
||||
<summary class="list-none cursor-pointer">
|
||||
<div class="grid gap-4 p-6 lg:grid-cols-[1.2fr_2fr_repeat(6,minmax(0,1fr))] lg:items-center">
|
||||
<div>
|
||||
<p class="text-xs uppercase tracking-[0.25em] text-slate-400">Submitter</p>
|
||||
<p class="mt-2 text-lg font-semibold text-slate-900">{{ .Submitter }}</p>
|
||||
<p class="mt-1 text-xs text-slate-500">{{ .SubmissionID }}</p>
|
||||
<p class="mt-2 text-lg font-semibold text-slate-900 dark:text-slate-100">{{ .Submitter }}</p>
|
||||
<p class="mt-1 text-xs text-slate-500 dark:text-slate-400">{{ .SubmissionID }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs uppercase tracking-[0.25em] text-slate-400">CPU</p>
|
||||
<p class="mt-2 font-semibold text-slate-900">{{ .CPUInfo.BrandString }}</p>
|
||||
<p class="mt-1 text-sm text-slate-500">{{ .CPUInfo.VendorID }} • {{ .CPUInfo.PhysicalCores }}C / {{ .CPUInfo.LogicalCores }}T</p>
|
||||
<p class="mt-2 font-semibold text-slate-900 dark:text-slate-100">{{ .CPUInfo.BrandString }}</p>
|
||||
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">{{ .CPUInfo.VendorID }} • {{ .CPUInfo.PhysicalCores }}C / {{ .CPUInfo.LogicalCores }}T</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs uppercase tracking-[0.25em] text-slate-400">Score</p>
|
||||
@@ -141,11 +188,11 @@
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs uppercase tracking-[0.25em] text-slate-400">MOps/sec</p>
|
||||
<p class="mt-2 text-xl font-semibold text-slate-900">{{ formatFloat .MOpsPerSec }}</p>
|
||||
<p class="mt-2 text-xl font-semibold text-slate-900 dark:text-slate-100">{{ formatFloat .MOpsPerSec }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs uppercase tracking-[0.25em] text-slate-400">Mode</p>
|
||||
<p class="mt-2 inline-flex rounded-full bg-slate-100 px-3 py-1 text-sm font-medium text-slate-700">{{ modeLabel .Config.MultiCore }}</p>
|
||||
<p class="mt-2 inline-flex rounded-full bg-slate-100 px-3 py-1 text-sm font-medium text-slate-700 dark:bg-slate-800 dark:text-slate-200">{{ modeLabel .Config.MultiCore }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs uppercase tracking-[0.25em] text-slate-400">Platform</p>
|
||||
@@ -153,56 +200,56 @@
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs uppercase tracking-[0.25em] text-slate-400">Intensity</p>
|
||||
<p class="mt-2 text-xl font-semibold text-slate-900">{{ .Config.Intensity }}</p>
|
||||
<p class="mt-2 text-xl font-semibold text-slate-900 dark:text-slate-100">{{ .Config.Intensity }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs uppercase tracking-[0.25em] text-slate-400">Run Time</p>
|
||||
<p class="mt-2 text-xl font-semibold text-slate-900">{{ .Config.DurationSecs }}s</p>
|
||||
<p class="mt-2 text-xl font-semibold text-slate-900 dark:text-slate-100">{{ .Config.DurationSecs }}s</p>
|
||||
</div>
|
||||
</div>
|
||||
</summary>
|
||||
|
||||
<div class="border-t border-slate-100 bg-slate-50 px-6 py-6">
|
||||
<div class="border-t border-slate-100 bg-slate-50 px-6 py-6 dark:border-slate-800 dark:bg-slate-950/70">
|
||||
<div class="grid gap-4 md:grid-cols-2 xl:grid-cols-6">
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm">
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm dark:bg-slate-900">
|
||||
<p class="text-xs uppercase tracking-[0.2em] text-slate-400">Started</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800">{{ formatTime .StartedAt }}</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800 dark:text-slate-200">{{ formatTime .StartedAt }}</p>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm">
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm dark:bg-slate-900">
|
||||
<p class="text-xs uppercase tracking-[0.2em] text-slate-400">Submitted</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800">{{ formatTime .SubmittedAt }}</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800 dark:text-slate-200">{{ formatTime .SubmittedAt }}</p>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm">
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm dark:bg-slate-900">
|
||||
<p class="text-xs uppercase tracking-[0.2em] text-slate-400">Total ops</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800">{{ formatInt64 .TotalOps }}</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800 dark:text-slate-200">{{ formatInt64 .TotalOps }}</p>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm">
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm dark:bg-slate-900">
|
||||
<p class="text-xs uppercase tracking-[0.2em] text-slate-400">Duration</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800">
|
||||
<p class="mt-2 text-sm font-medium text-slate-800 dark:text-slate-200">
|
||||
{{ .Config.DurationSecs }} seconds
|
||||
</p>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm">
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm dark:bg-slate-900">
|
||||
<p class="text-xs uppercase tracking-[0.2em] text-slate-400">Intensity</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800">
|
||||
<p class="mt-2 text-sm font-medium text-slate-800 dark:text-slate-200">
|
||||
{{ .Config.Intensity }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm">
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm dark:bg-slate-900">
|
||||
<p class="text-xs uppercase tracking-[0.2em] text-slate-400">Core Filter</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800">
|
||||
<p class="mt-2 text-sm font-medium text-slate-800 dark:text-slate-200">
|
||||
{{ .Config.CoreFilter }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm">
|
||||
<div class="rounded-2xl bg-white p-4 shadow-sm dark:bg-slate-900">
|
||||
<p class="text-xs uppercase tracking-[0.2em] text-slate-400">Platform</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800">{{ .Platform }}</p>
|
||||
<p class="mt-2 text-sm font-medium text-slate-800 dark:text-slate-200">{{ .Platform }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 overflow-x-auto rounded-2xl border border-slate-200 bg-white">
|
||||
<table class="min-w-full divide-y divide-slate-200 text-sm">
|
||||
<thead class="bg-slate-100 text-slate-600">
|
||||
<div class="mt-6 overflow-x-auto rounded-2xl border border-slate-200 bg-white dark:border-slate-800 dark:bg-slate-900">
|
||||
<table class="min-w-full divide-y divide-slate-200 text-sm dark:divide-slate-800">
|
||||
<thead class="bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-300">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left font-semibold">Logical ID</th>
|
||||
<th class="px-4 py-3 text-left font-semibold">Core Type</th>
|
||||
@@ -210,17 +257,17 @@
|
||||
<th class="px-4 py-3 text-left font-semibold">Total Ops</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100">
|
||||
<tbody class="divide-y divide-slate-100 dark:divide-slate-800">
|
||||
{{ range .CoreResults }}
|
||||
<tr>
|
||||
<td class="px-4 py-3 font-medium text-slate-900">{{ .LogicalID }}</td>
|
||||
<td class="px-4 py-3 text-slate-700">{{ .CoreType }}</td>
|
||||
<td class="px-4 py-3 text-slate-700">{{ formatFloat .MOpsPerSec }}</td>
|
||||
<td class="px-4 py-3 text-slate-700">{{ formatInt64 .TotalOps }}</td>
|
||||
<td class="px-4 py-3 font-medium text-slate-900 dark:text-slate-100">{{ .LogicalID }}</td>
|
||||
<td class="px-4 py-3 text-slate-700 dark:text-slate-300">{{ .CoreType }}</td>
|
||||
<td class="px-4 py-3 text-slate-700 dark:text-slate-300">{{ formatFloat .MOpsPerSec }}</td>
|
||||
<td class="px-4 py-3 text-slate-700 dark:text-slate-300">{{ formatInt64 .TotalOps }}</td>
|
||||
</tr>
|
||||
{{ else }}
|
||||
<tr>
|
||||
<td colspan="4" class="px-4 py-6 text-center text-slate-500">No per-core results available.</td>
|
||||
<tr class="dark:bg-slate-900">
|
||||
<td colspan="4" class="px-4 py-6 text-center text-slate-500 dark:text-slate-400">No per-core results available.</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
@@ -232,24 +279,59 @@
|
||||
</section>
|
||||
|
||||
{{ if gt .TotalPages 1 }}
|
||||
<nav class="mt-8 flex flex-col gap-3 rounded-2xl bg-white p-5 shadow-sm md:flex-row md:items-center md:justify-between">
|
||||
<div class="text-sm text-slate-500">
|
||||
<nav class="mt-8 flex flex-col gap-3 rounded-2xl bg-white p-5 shadow-sm md:flex-row md:items-center md:justify-between dark:bg-slate-900 dark:shadow-black/20">
|
||||
<div class="text-sm text-slate-500 dark:text-slate-400">
|
||||
Page {{ .Page }} of {{ .TotalPages }}
|
||||
</div>
|
||||
<div class="flex gap-3">
|
||||
{{ if gt .Page 1 }}
|
||||
<a href="{{ .PrevURL }}" class="rounded-xl border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50">Previous</a>
|
||||
<a href="{{ .PrevURL }}" class="rounded-xl border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800">Previous</a>
|
||||
{{ else }}
|
||||
<span class="cursor-not-allowed rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-400">Previous</span>
|
||||
<span class="cursor-not-allowed rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-400 dark:border-slate-800 dark:text-slate-600">Previous</span>
|
||||
{{ end }}
|
||||
{{ if lt .Page .TotalPages }}
|
||||
<a href="{{ .NextURL }}" class="rounded-xl bg-slate-900 px-4 py-2 text-sm font-medium text-white transition hover:bg-slate-700">Next</a>
|
||||
<a href="{{ .NextURL }}" class="rounded-xl bg-slate-900 px-4 py-2 text-sm font-medium text-white transition hover:bg-slate-700 dark:bg-cyan-600 dark:hover:bg-cyan-500">Next</a>
|
||||
{{ else }}
|
||||
<span class="cursor-not-allowed rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-400">Next</span>
|
||||
<span class="cursor-not-allowed rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-400 dark:border-slate-800 dark:text-slate-600">Next</span>
|
||||
{{ end }}
|
||||
</div>
|
||||
</nav>
|
||||
{{ end }}
|
||||
</main>
|
||||
<script>
|
||||
(function() {
|
||||
var storageKey = "cpu-benchmark-theme";
|
||||
var root = document.documentElement;
|
||||
var button = document.getElementById("theme-toggle");
|
||||
var icon = document.getElementById("theme-toggle-icon");
|
||||
var label = document.getElementById("theme-toggle-label");
|
||||
|
||||
if (!button || !icon || !label) {
|
||||
return;
|
||||
}
|
||||
|
||||
function applyTheme(theme, persist) {
|
||||
currentTheme = theme;
|
||||
root.classList.toggle("dark", theme === "dark");
|
||||
root.dataset.theme = theme;
|
||||
button.setAttribute("aria-pressed", String(theme === "dark"));
|
||||
icon.textContent = theme === "dark" ? "☾" : "☼";
|
||||
label.textContent = theme === "dark" ? "Dark" : "Light";
|
||||
|
||||
if (persist) {
|
||||
try {
|
||||
localStorage.setItem(storageKey, theme);
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
|
||||
var currentTheme = root.dataset.theme === "dark" ? "dark" : "light";
|
||||
applyTheme(currentTheme, false);
|
||||
|
||||
button.addEventListener("click", function() {
|
||||
applyTheme(currentTheme === "dark" ? "light" : "dark", true);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user