Skip to content

Commit

Permalink
limit frame rate to 60 frames per second (#100)
Browse files Browse the repository at this point in the history
* limit frame rate to 60 frames per second

Note that the average frame rate we observe seems to be a little less than 60 frames per second. One may want to tune the max_frames_per_second accordingly.

* update example screenshot
  • Loading branch information
Sid-Bhatia-0 authored Feb 3, 2023
1 parent 248d84e commit 60f7316
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ julia --project=. example.jl

This will open a window and you can interact with the widgets present in it. Here is a screenshot

<img src="https://user-images.githubusercontent.com/32610387/213902028-ede69c75-f36c-4df2-9d8b-4db107aabe13.png">
<img src="https://user-images.githubusercontent.com/32610387/216698734-400e1dcb-ff51-4a53-b6e3-87d5f7b60570.png">

# References:

Expand Down
5 changes: 5 additions & 0 deletions examples/example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ function start()

sliding_window_size = 30

max_frames_per_second = 60
min_seconds_per_frame = 1 / max_frames_per_second

frame_time_stamp_buffer = DS.CircularBuffer{typeof(time_ns())}(sliding_window_size)
push!(frame_time_stamp_buffer, time_ns())

Expand Down Expand Up @@ -399,6 +402,8 @@ function start()

i = i + 1

sleep(max(0.0, min_seconds_per_frame - (time_ns() - last(frame_time_stamp_buffer)) / 1e9))

push!(frame_time_stamp_buffer, time_ns())
end

Expand Down

0 comments on commit 60f7316

Please sign in to comment.