Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
cb55a19ada | ||
|
352950467c | ||
|
abc4abe80e | ||
|
ff8acd493b | ||
|
4b98322022 | ||
60d8554cf1 | |||
c19bb2108c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,6 +3,7 @@ blt
|
|||||||
|
|
||||||
# Local data files
|
# Local data files
|
||||||
data/
|
data/
|
||||||
|
tmp/
|
||||||
|
|
||||||
# Compiled assets
|
# Compiled assets
|
||||||
public/css/
|
public/css/
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
pipeline:
|
steps:
|
||||||
build:
|
build:
|
||||||
image: golang:1.22
|
image: golang:1.22
|
||||||
commands:
|
commands:
|
||||||
|
54
README.md
Normal file
54
README.md
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# Benchmark Logging Tool (BLT)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Web-based tool to store and organize PC hardware benchmarks.
|
||||||
|
|
||||||
|
## Project Goals
|
||||||
|
|
||||||
|
The goals of this project are to:
|
||||||
|
|
||||||
|
* Record benchmarking results from multiple devices - e.g. log from a laptop or a phone.
|
||||||
|
* Group results into tests to keep track of different testing configurations.
|
||||||
|
* Encourage running tests multiple times - it's good practice to run a benchmark multiple times for accuracy.
|
||||||
|
* Create comparisons of hardware tests to compare performance.
|
||||||
|
* Generate graphs of hardware comparisons for usage in videos and articles.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
BLT runs on Go. It uses the built-in `go mod` tool to manage dependencies, thus there is no external tooling to install to build/run BLT.
|
||||||
|
|
||||||
|
Debian/Ubuntu: `apt install -y golang`
|
||||||
|
RedHat and clones: `dnf install -y golang`
|
||||||
|
|
||||||
|
## Production Deployment
|
||||||
|
|
||||||
|
**TODO**
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### Via Docker
|
||||||
|
|
||||||
|
**TODO**
|
||||||
|
|
||||||
|
### Local/Native Development
|
||||||
|
|
||||||
|
BLT uses [fresh](https://github.com/gravityblast/fresh) to auto-reload the app. While this is not strictly necessary, it used to make development more convenient. If you wish to forego installing it, you may simply build and run the app with the standard `go run main.go`.
|
||||||
|
|
||||||
|
1. Install dependencies:
|
||||||
|
|
||||||
|
`go mod download`
|
||||||
|
|
||||||
|
2. Install fresh to auto-reload the app:
|
||||||
|
|
||||||
|
`go install github.com/gravityblast/fresh@latest`
|
||||||
|
|
||||||
|
3. Run the app via air:
|
||||||
|
|
||||||
|
`fresh`
|
||||||
|
|
||||||
|
4. If everything is running successfully you can open your browser and go to http://localhost:2830.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is available under the BSD 2-Clause license.
|
@@ -1,6 +1,8 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,3 +18,7 @@ type Benchmark struct {
|
|||||||
// has many results
|
// has many results
|
||||||
Results []Result
|
Results []Result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Benchmark) StringID() string {
|
||||||
|
return strconv.Itoa(int(b.ID))
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,3 +21,24 @@ type Test struct {
|
|||||||
// has many results
|
// has many results
|
||||||
Results []Result
|
Results []Result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Test) SelectedBenchmarks() []string {
|
||||||
|
benchmarks := t.Benchmarks
|
||||||
|
ids := make([]string, len(benchmarks))
|
||||||
|
for i, b := range benchmarks {
|
||||||
|
ids[i] = strconv.Itoa(int(b.ID))
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Test) IsBenchmarkSelected(benchmarkID uint) bool {
|
||||||
|
benchmarkUint := uint(benchmarkID)
|
||||||
|
|
||||||
|
for _, b := range t.Benchmarks {
|
||||||
|
if b.ID == benchmarkUint {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
14
runner.conf
Normal file
14
runner.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
root: .
|
||||||
|
tmp_path: ./tmp
|
||||||
|
build_name: runner-build
|
||||||
|
build_log: runner-build-errors.log
|
||||||
|
valid_ext: .go, .tpl, .tmpl, .html
|
||||||
|
no_rebuild_ext: .tpl, .tmpl, .html
|
||||||
|
ignored: assets, tmp, node_modules, data, vendor
|
||||||
|
build_delay: 600
|
||||||
|
colors: 1
|
||||||
|
log_color_main: cyan
|
||||||
|
log_color_build: yellow
|
||||||
|
log_color_runner: green
|
||||||
|
log_color_watcher: magenta
|
||||||
|
log_color_app:
|
@@ -30,9 +30,9 @@
|
|||||||
<label for="test_benchmarks">
|
<label for="test_benchmarks">
|
||||||
Benchmarks to Test:
|
Benchmarks to Test:
|
||||||
<select id="test_benchmarks" class="u-full-width" name="test_benchmarks" multiple>
|
<select id="test_benchmarks" class="u-full-width" name="test_benchmarks" multiple>
|
||||||
{{ $testBenchmarks := .test.Benchmarks }}
|
{{ $selectedBenchmarks := .selectedBenchmarks }}
|
||||||
{{ range $bm := .benchmarks }}
|
{{ range $bm := .benchmarks }}
|
||||||
<option value="{{ $bm.ID }}" {{ if contains $testBenchmarks $bm.ID }}selected{{ end }}>{{ $bm.Name }}</option>
|
<option value="{{ $bm.ID }}" {{ if contains $selectedBenchmarks $bm.StringID }}selected{{ end }}>{{ $bm.Name }}</option>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
@@ -4,5 +4,15 @@ type TestForm struct {
|
|||||||
Name string `form:"test_name" validate:"required"`
|
Name string `form:"test_name" validate:"required"`
|
||||||
Description string `form:"test_description"`
|
Description string `form:"test_description"`
|
||||||
Hardware int `form:"test_hardware" validate:"required"`
|
Hardware int `form:"test_hardware" validate:"required"`
|
||||||
Benchmarks []string `form:"test_benchmarks" validate:"required"`
|
Benchmarks []uint `form:"test_benchmarks" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TestForm) IsBenchmarkSelected(checkID uint) bool {
|
||||||
|
for _, selectedID := range t.Benchmarks {
|
||||||
|
if checkID == selectedID {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,7 @@ func RegisterRoutes(f *flamego.Flame) {
|
|||||||
f.Group("/{test_id}", func() {
|
f.Group("/{test_id}", func() {
|
||||||
f.Get("", routes.TestGetView)
|
f.Get("", routes.TestGetView)
|
||||||
f.Get("/edit", routes.TestGetEdit)
|
f.Get("/edit", routes.TestGetEdit)
|
||||||
|
f.Post("/edit", binding.Form(forms.TestForm{}), routes.TestPostEdit)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -99,6 +99,54 @@ func TestGetEdit(c flamego.Context, t template.Template, data template.Data) {
|
|||||||
models.DB.Find(&benchmarks)
|
models.DB.Find(&benchmarks)
|
||||||
data["benchmarks"] = benchmarks
|
data["benchmarks"] = benchmarks
|
||||||
|
|
||||||
|
// determine which benchmarks are selected in a test
|
||||||
|
selectedBenchmarks := test.SelectedBenchmarks()
|
||||||
|
data["selectedBenchmarks"] = selectedBenchmarks
|
||||||
|
|
||||||
data["title"] = fmt.Sprintf("Editing Test: %s", test.Name)
|
data["title"] = fmt.Sprintf("Editing Test: %s", test.Name)
|
||||||
t.HTML(http.StatusOK, "test/edit")
|
t.HTML(http.StatusOK, "test/edit")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPostEdit(c flamego.Context, form forms.TestForm, errs binding.Errors) {
|
||||||
|
if len(errs) > 0 {
|
||||||
|
var err error
|
||||||
|
switch errs[0].Category {
|
||||||
|
case binding.ErrorCategoryValidation:
|
||||||
|
err = errs[0].Err.(validator.ValidationErrors)[0]
|
||||||
|
default:
|
||||||
|
err = errs[0].Err
|
||||||
|
}
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// find test ID from request
|
||||||
|
testID := c.Param("test_id")
|
||||||
|
|
||||||
|
// find hardware from DB
|
||||||
|
var test models.Test
|
||||||
|
models.DB.Preload("Hardware").Preload("Benchmarks").First(&test, testID)
|
||||||
|
|
||||||
|
test.Name = form.Name
|
||||||
|
test.Description = form.Description
|
||||||
|
test.HardwareID = form.Hardware
|
||||||
|
|
||||||
|
// bind benchmarks to test that aren't already associated
|
||||||
|
for _, b := range form.Benchmarks {
|
||||||
|
if ! test.IsBenchmarkSelected(b) {
|
||||||
|
var benchmark models.Benchmark
|
||||||
|
models.DB.First(&benchmark, b) // find benchmark
|
||||||
|
models.DB.Model(&test).Association("Benchmarks").Append(&benchmark)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// removed associated benchmarks that weren't in the form
|
||||||
|
for _, b := range test.Benchmarks {
|
||||||
|
if ! form.IsBenchmarkSelected(b.ID) {
|
||||||
|
var benchmark models.Benchmark
|
||||||
|
models.DB.First(&benchmark, b) // find benchmark
|
||||||
|
models.DB.Model(&test).Association("Benchmarks").Delete(&benchmark)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Redirect(fmt.Sprintf("/test/%d", test.ID))
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user