Skip to content

Commit

Permalink
Add killtime option to bench
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSchinazi committed Jan 8, 2025
1 parent 0e8a480 commit 7d865c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/jazzlights.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
run: cmake -S extras -B extras/build
- name: Build
run: cmake --build extras/build
- name: Run jazzlights-demo
run: extras/build/jazzlights-demo -k 1
- name: Run jazzlights-bench
run: extras/build/jazzlights-bench -k 2

pio-build:
strategy:
Expand Down
16 changes: 14 additions & 2 deletions extras/bench/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <getopt.h>

#include "jazzlights/layout/matrix.h"
#include "jazzlights/player.h"
#include "jazzlights/util/log.h"
Expand All @@ -15,12 +17,22 @@ class NoopRenderer : public Renderer {

NoopRenderer noopRenderer;

int runMain() {
int runMain(int argc, char** argv) {
int killTime = 0;
while (true) {
int ch = getopt(argc, argv, "k:");
if (ch == -1) { break; }
if (ch == 'k') { killTime = strtol(optarg, nullptr, 10) * 1000; }
}
player.addStrand(pixels, noopRenderer);
player.begin(timeMillis());
Milliseconds lastFpsEpochTime = 0;
while (true) {
const Milliseconds currentTime = timeMillis();
if (killTime > 0 && currentTime > killTime) {
jll_info("Kill time reached, exiting.");
exit(0);
}
if (currentTime - lastFpsEpochTime > 1000) {
uint16_t fpsCompute;
uint16_t fpsWrites;
Expand All @@ -38,4 +50,4 @@ int runMain() {

} // namespace jazzlights

int main(int /*argc*/, char** /*argv*/) { return jazzlights::runMain(); }
int main(int argc, char** argv) { return jazzlights::runMain(argc, argv); }

0 comments on commit 7d865c4

Please sign in to comment.