|
9 | 9 | # Busy loop: 22289 iterations/second |
10 | 10 | # Busy loop with yield: 15923 iterations/second |
11 | 11 | # SHA-256 (1KB): 5269 iterations/second |
| 12 | +# |
| 13 | +# New way, with the tests in a thread, replacing appscreen == lv.screen_active() with keeprunning: |
| 14 | +# Busy loop: 127801 iterations/second |
| 15 | +# Busy loop with yield: 38394 iterations/second |
| 16 | +# SHA-256 (1KB): 5012 iterations/second |
12 | 17 |
|
13 | 18 | import time |
14 | 19 | import hashlib |
|
19 | 24 | summary = "Running 3 CPU tests...\n\n" |
20 | 25 |
|
21 | 26 | # Configuration |
| 27 | +START_SPACING = 2000 # Wait for system to settle |
22 | 28 | TEST_DURATION = 5000 # Duration of each test (ms) |
23 | 29 | TEST_SPACING = 1000 # Wait between tests (ms) |
24 | | -DATA_SIZE = 1024 # 1KB of data for SHA-256 test |
25 | | -DATA = os.urandom(DATA_SIZE) # Generate 1KB of random data for SHA-256 |
26 | 30 |
|
27 | 31 | def stress_test_thread(): |
28 | | - print("\nStarting busy loop stress test...") |
| 32 | + DATA_SIZE = 1024 # 1KB of data for SHA-256 test |
| 33 | + DATA = os.urandom(DATA_SIZE) # Generate 1KB of random data for SHA-256 |
| 34 | + print("stress_test_thread running") |
29 | 35 | global summary, keeprunning |
| 36 | + summary += "Waiting for system to settle...\n\n" |
| 37 | + time.sleep_ms(START_SPACING) |
30 | 38 | summary += "Busy loop without yield: " |
31 | 39 | iterations = 0 |
32 | 40 | start_time = time.ticks_ms() |
@@ -77,8 +85,8 @@ def janitor_cb(timer): |
77 | 85 | update_status_timer.delete() |
78 | 86 |
|
79 | 87 | appscreen = lv.screen_active() |
80 | | -janitor = lv.timer_create(janitor_cb, 500, None) |
81 | | -update_status_timer = lv.timer_create(lambda timer: status.set_text(summary), 200, None) |
| 88 | +janitor = lv.timer_create(janitor_cb, 1000, None) |
| 89 | +update_status_timer = lv.timer_create(lambda timer: status.set_text(summary), 750, None) |
82 | 90 |
|
83 | 91 | status = lv.label(appscreen) |
84 | 92 | status.align(lv.ALIGN.TOP_LEFT, 5, 10) |
|
0 commit comments