gregjohnson2017 / tabula-editor

An image editor built from scratch with OpenGL in Go.
MIT License
7 stars 0 forks source link

Add loggers for debugging & performance, and add corresponding CLI flags #54

Closed kroppt closed 4 years ago

gregjohnson2017 commented 4 years ago

If you use the fps flag with a value equal to or less than 0, the program crashes:

gregj@BigBeakWindows MINGW64 ~/Projects/tabula-editor (add-logging)
$ ./tabula-editor.exe -fps 0
INFO 2020/07/19 12:38:17 Using file dialog to get file name
panic: runtime error: integer divide by zero

goroutine 1 [running, locked to thread]:
github.com/gregjohnson2017/tabula-editor/pkg/app.New(0xc000112090, 0x22, 0x1c6beb0, 0xc00000c580, 0x0)
        C:/Users/gregj/Projects/tabula-editor/pkg/app/app.go:176 +0xd7f
main.main()
        C:/Users/gregj/Projects/tabula-editor/main.go:141 +0x8c8
gregjohnson2017 commented 4 years ago

In the -perf flag to see performance metrics, it is useful to see the average time to render different components on the screen per frame, but for something like the MapString function in font.go, seeing the average run time lacks the context of how many times per frame it is being called, so seeing PERF 2020/07/19 12:42:10.809583 perf.go:54: - font.MapString = 1.029µs doesn't mean much. Thoughts on adding # of calls per frame? This would affect buttons too, because there are multiple of them... might be a good idea to add # of calls for each

Also maybe total computation time per frame, and compare that to fps and log a warning if the computation time exceeds the frame time

gregjohnson2017 commented 4 years ago

Thoughts on just making the option of launching with a file name just be a flag like -file <name>? Right now if you get the order wrong like ./tabula-editor.exe happyhug.png -fps 60 it will just start and ignore the flags because they aren't in the right order without warning you.

gregjohnson2017 commented 4 years ago

The refresh rate range seems to be coming up with a strange lower bound for me: WARN 2020/08/07 11:49:45 framerate 60 not within set refresh rate range 144-144 Why wouldn't I be able to go lower than 144?

kroppt commented 4 years ago

The refresh rate range seems to be coming up with a strange lower bound for me: WARN 2020/08/07 11:49:45 framerate 60 not within set refresh rate range 144-144 Why wouldn't I be able to go lower than 144?

The range represents the minimum to maximum refresh rates of all the monitors. So a 60hz and 144hz monitor would have the range 60-144. I haven't really been able to test it, though. It's just a warning, so you can do it without anything breaking. You can interpret the warning as, "I set my framerate to a value lower than what my refresh rate is," which is frowned upon. Maybe we can have a way to align these automatically.