2024-07-23 23:00:19 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-07-23 23:37:02 +00:00
|
|
|
"flag"
|
2024-07-23 23:00:19 +00:00
|
|
|
"fmt"
|
|
|
|
"log"
|
2024-07-23 23:37:02 +00:00
|
|
|
"os"
|
|
|
|
"runtime/pprof" // For performance whatever
|
2024-07-23 23:00:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2024-07-24 00:19:03 +00:00
|
|
|
Width = 512
|
|
|
|
Height = 512
|
|
|
|
LineRepeat = 1_000_000
|
2024-07-23 23:00:19 +00:00
|
|
|
)
|
|
|
|
|
2024-07-23 23:37:02 +00:00
|
|
|
func must(err error) {
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// However flag works... idk
|
|
|
|
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
|
|
|
|
|
2024-07-23 23:00:19 +00:00
|
|
|
func main() {
|
|
|
|
log.Printf("Program start")
|
2024-07-23 23:37:02 +00:00
|
|
|
|
|
|
|
// Little section for doing cpu profiling. I guess that's all you have to do?
|
|
|
|
flag.Parse()
|
|
|
|
if *cpuprofile != "" {
|
|
|
|
log.Printf("CPU profiling requested, write to %s", *cpuprofile)
|
|
|
|
f, err := os.Create(*cpuprofile)
|
|
|
|
must(err)
|
|
|
|
defer f.Close()
|
|
|
|
err = pprof.StartCPUProfile(f)
|
|
|
|
must(err)
|
|
|
|
defer pprof.StopCPUProfile()
|
|
|
|
}
|
|
|
|
|
2024-07-23 23:00:19 +00:00
|
|
|
fb := NewFramebuffer(Width, Height)
|
2024-07-23 23:37:02 +00:00
|
|
|
|
|
|
|
log.Printf("Running render")
|
|
|
|
|
2024-07-24 00:19:03 +00:00
|
|
|
// Just draw a simple line (a million times or something)
|
|
|
|
for range LineRepeat {
|
|
|
|
LineDumb3(&fb, 0xFFFFFF, 100, 100, 350, 200)
|
|
|
|
LineDumb3(&fb, 0xFF0000, 120, 100, 200, 350)
|
|
|
|
LineDumb3(&fb, 0xFF0000, 350, 200, 100, 100) // backward first line
|
|
|
|
}
|
2024-07-23 23:37:02 +00:00
|
|
|
|
|
|
|
log.Printf("Exporting ppm to stdout")
|
2024-07-23 23:00:19 +00:00
|
|
|
fmt.Print(fb.ExportPPM())
|
2024-07-23 23:37:02 +00:00
|
|
|
|
2024-07-23 23:00:19 +00:00
|
|
|
log.Printf("Program end")
|
|
|
|
}
|