Skip to content

Commit

Permalink
Naming conventions and table layout
Browse files Browse the repository at this point in the history
  • Loading branch information
bhperry committed Aug 23, 2024
1 parent aeaa07d commit 564f563
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
22 changes: 11 additions & 11 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ go tool pprof -http :9000 cpu.prof
Information about the machines used to record benchmark stats

| Machine | OS/Distro | CPU | Memory | GPU |
| ------------------ | ------------------- | ----------------------------- | ------------------ | -------------- |
|--------------------|---------------------|-------------------------------|--------------------|----------------|
| bhperry-wsl | Linux Ubuntu 20.04 | Intel i7-8086K @ 4.00GHz | 8GiB | RTX 2080 |
| bhperry-win10 | Windows 10 | Intel i7-8086K @ 4.00GHz | 16GiB | RTX 2080 |

### Stats

| Machine | Pixel | Benchmark | Duration | Frames | FPS Avg | FPS Min | FPS Max | FPS Stdev |
|--------------------|--------|------------------|----------|----------|----------|----------|----------|-----------|
| bhperry-wsl | v2.2.0 | imdraw-moving | 30s | 2193 | 73.1 | 66 | 76 | 2.73 |
| bhperry-wsl | v2.2.0 | imdraw-static | 30.01s | 2344 | 78.1 | 70 | 80 | 1.67 |
| bhperry-wsl | v2.2.0 | sprite | 30.01s | 1509 | 50.29 | 47 | 52 | 1.15 |
| bhperry-wsl | v2.2.0 | sprite-batched | 30.01s | 5187 | 172.83 | 153 | 178 | 4.57 |
| bhperry-win10 | v2.2.0 | imdraw-moving | 30s | 1436 | 47.86 | 23 | 50 | 5.92 |
| bhperry-win10 | v2.2.0 | imdraw-static | 30.03s | 1570 | 52.28 | 51 | 53 | 0.53 |
| bhperry-win10 | v2.2.0 | sprite | 30.03s | 1242 | 41.36 | 40 | 42 | 0.6 |
| bhperry-win10 | v2.2.0 | sprite-batched | 30s | 40957 | 1365.23 | 1254 | 1383 | 23.39 |
| Machine | Pixel | Benchmark | Duration | Frames | FPS Avg | FPS Min | FPS Max | FPS Stdev |
|--------------------|--------|------------------------------|----------|--------|----------|----------|----------|-----------|
| bhperry-wsl | v2.2.0 | imdraw-moving | 30s | 2193 | 73.1 | 66 | 76 | 2.73 |
| bhperry-wsl | v2.2.0 | imdraw-static | 30.01s | 2344 | 78.1 | 70 | 80 | 1.67 |
| bhperry-wsl | v2.2.0 | sprite-static | 30.01s | 1509 | 50.29 | 47 | 52 | 1.15 |
| bhperry-wsl | v2.2.0 | sprite-static-batched | 30.01s | 5187 | 172.83 | 153 | 178 | 4.57 |
| bhperry-win10 | v2.2.0 | imdraw-moving | 30s | 1436 | 47.86 | 23 | 50 | 5.92 |
| bhperry-win10 | v2.2.0 | imdraw-static | 30.03s | 1570 | 52.28 | 51 | 53 | 0.53 |
| bhperry-win10 | v2.2.0 | sprite-static | 30.03s | 1242 | 41.36 | 40 | 42 | 0.6 |
| bhperry-win10 | v2.2.0 | sprite-static-batched | 30s | 40957 | 1365.23 | 1254 | 1383 | 23.39 |
44 changes: 22 additions & 22 deletions tools/benchmark/sprite_bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,32 @@ func init() {

Benchmarks.Add(
Config{
Name: "sprite",
Name: "sprite-static",
Description: "Draw a sprite to the window in a grid",
New: newSingleSprite,
New: newSpriteStatic,
Duration: 30 * time.Second,
},
Config{
Name: "sprite-batched",
Name: "sprite-static-batched",
Description: "Draw a sprite to the window in a grid with batched draw",
New: newBatchedSprite,
New: newSpriteBatched,
Duration: 30 * time.Second,
},
)
}

func newSingleSprite() Benchmark {
return &singleSprite{rows: 32, cols: 32}
func newSpriteStatic() Benchmark {
return &spriteStatic{rows: 32, cols: 32}
}

type singleSprite struct {
type spriteStatic struct {
sprite *pixel.Sprite
rows, cols int
width, height float64
cell pixel.Vec
}

func (ss *singleSprite) Init(win *opengl.Window) error {
func (ss *spriteStatic) Init(win *opengl.Window) error {
sprite, err := loadSprite(logoPath, logoFrame)
if err != nil {
return err
Expand All @@ -64,42 +64,42 @@ func (ss *singleSprite) Init(win *opengl.Window) error {
return nil
}

func (ss *singleSprite) Step(win *opengl.Window) {
func (ss *spriteStatic) Step(win *opengl.Window) {
win.Clear(backgroundColor)
spriteGrid(ss.sprite, win, ss.rows, ss.cols, ss.cell)
}

func newBatchedSprite() Benchmark {
return &batchedSprite{rows: 32, cols: 32}
func newSpriteBatched() Benchmark {
return &spriteBatched{rows: 32, cols: 32}
}

type batchedSprite struct {
type spriteBatched struct {
sprite *pixel.Sprite
batch *pixel.Batch
rows, cols int
width, height float64
cell pixel.Vec
}

func (bs *batchedSprite) Init(win *opengl.Window) error {
func (sb *spriteBatched) Init(win *opengl.Window) error {
sprite, err := loadSprite(logoPath, logoFrame)
if err != nil {
return err
}
bs.sprite = sprite
bs.batch = pixel.NewBatch(&pixel.TrianglesData{}, sprite.Picture())
sb.sprite = sprite
sb.batch = pixel.NewBatch(&pixel.TrianglesData{}, sprite.Picture())
bounds := win.Bounds()
bs.width = bounds.W()
bs.height = bounds.H()
bs.cell = gridCell(bs.width, bs.height, bs.rows, bs.cols)
sb.width = bounds.W()
sb.height = bounds.H()
sb.cell = gridCell(sb.width, sb.height, sb.rows, sb.cols)
return nil
}

func (bs *batchedSprite) Step(win *opengl.Window) {
func (sb *spriteBatched) Step(win *opengl.Window) {
win.Clear(backgroundColor)
bs.batch.Clear()
spriteGrid(bs.sprite, bs.batch, bs.rows, bs.cols, bs.cell)
bs.batch.Draw(win)
sb.batch.Clear()
spriteGrid(sb.sprite, sb.batch, sb.rows, sb.cols, sb.cell)
sb.batch.Draw(win)
}

func spriteGrid(sprite *pixel.Sprite, target pixel.Target, rows, cols int, cell pixel.Vec) {
Expand Down
4 changes: 2 additions & 2 deletions tools/benchmark/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ func (sc StatsCollection) Print() {
widths := map[string]int{
"Machine": 18,
"Pixel": 6,
"Benchmark": 16,
"Benchmark": 28,
}
for i, header := range headers {
minWidth := widths[header]
if minWidth == 0 {
minWidth = 8
minWidth = 6
}
table.SetColMinWidth(i, minWidth)
}
Expand Down

0 comments on commit 564f563

Please sign in to comment.