added custom test code

This commit is contained in:
paul-loedige 2022-12-26 14:07:19 +09:00
parent a128c8ae63
commit ce02078a6c
3 changed files with 2236 additions and 0 deletions

1094
no_preempt_rt.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 28 KiB

34
test.py Normal file
View File

@ -0,0 +1,34 @@
import subprocess
import time
import matplotlib.pyplot as plt
ITERATIONS = 300
ITERATION_DURATION = 1 #second(s)
def set_rt_priority():
subprocess.run(["schedtool", "-F", "-p", "99"], check=True)
def rt_task():
new_time = time.time()
jitter_record = []
for i in range(ITERATIONS + 1):
old_time = new_time
new_time = time.time()
print("--------------------------------------------------")
print(f"system time:\t{new_time} s")
print(f"time diff:\t{new_time - old_time} s")
jitter = new_time - old_time - ITERATION_DURATION
jitter_record.append(jitter)
print(f"jitter:\t{jitter} s")
time.sleep(new_time + ITERATION_DURATION - time.time())
jitter_record.pop(0)
plt.plot(jitter_record)
plt.title(f"Jitter at {ITERATION_DURATION} s interval")
plt.xlabel("Iteration")
plt.ylabel("Jitter (in s)")
plt.savefig("out.svg")
if __name__ == "__main__":
set_rt_priority()
rt_task()

1108
with_preempt_rt.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 28 KiB