import upstream maccel baseline
Tests / test_core_function (push) Failing after 12s

This commit is contained in:
2026-03-24 12:10:31 +00:00
parent 6e948d7b39
commit 5f1254d11a
108 changed files with 18930 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
*.o
bin
venv
+13
View File
@@ -0,0 +1,13 @@
bench_driver: build
@bin/evdriverlag
bench_handler: build
@bin/evinputlag
build: evdriverlag.c evinputlag.c
@mkdir -p bin
@cc evdriverlag.c -o bin/evdriverlag
@cc evinputlag.c -o bin/evinputlag
clean:
rm *.o
+1001
View File
File diff suppressed because it is too large Load Diff
+54
View File
@@ -0,0 +1,54 @@
#include <fcntl.h>
#include <linux/input.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#define MOUSE_DEVICE "/dev/input/event2"
static __suseconds_t to_us(struct timeval time) {
return time.tv_sec * 1000000L + time.tv_usec;
}
#define EVENT_TIME_PAIR_CNT 1000 * 2
int main(void) {
// Open the source device
int fd_source = open(MOUSE_DEVICE, O_RDONLY);
if (fd_source < 0) {
perror("Failed to open source device");
return 1;
}
__suseconds_t times[EVENT_TIME_PAIR_CNT] = {0};
int tidx = 0;
// Main loop to read, modify, and write events
struct input_event ev;
while (tidx < EVENT_TIME_PAIR_CNT && read(fd_source, &ev, sizeof(ev)) > 0) {
struct timeval now;
gettimeofday(&now, NULL);
times[tidx++] = to_us(ev.time);
times[tidx++] = to_us(now);
}
// Cleanup
close(fd_source);
tidx = 0;
printf("event_time,read_time,diff\n"); // eve'ry is in us
while (tidx < EVENT_TIME_PAIR_CNT) {
__suseconds_t event_time = times[tidx++];
__suseconds_t read_time = times[tidx++];
/* __suseconds_t diff = ; */
/* printf("event time: %luus, read time: %luus\n", event_time, read_time);
*/
/* printf("time diff: %luus\n", read_time - event_time); */
printf("%lu,%lu,%lu\n", event_time, read_time, read_time - event_time);
}
return 0;
}
+69
View File
@@ -0,0 +1,69 @@
#include <fcntl.h>
#include <linux/input.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#define MOUSE_DEVICE "/dev/input/event7"
static __suseconds_t to_us(struct timeval time) {
return time.tv_sec * 1000000L + time.tv_usec;
}
#define EVENT_TIME_PAIR_CNT 1000 * 3
/**
* NOTE: This benchmark depends on temporarily setting
* maccel_filter from input_handler.h to inject ktime_t diff (in us)
* between when the original event was received and the modified event was
* reported, as the value of the REL_Z REL_ABS event. So we can measure the
* extra lag from the input_handler. Assuming REL_Z, REL_ABS are only produced
* as carriers of the extra lag measurement.
*
*/
int main(void) {
int fd_source = open(MOUSE_DEVICE, O_RDONLY);
if (fd_source < 0) {
perror("Failed to open device");
return 1;
}
__suseconds_t times[EVENT_TIME_PAIR_CNT] = {0};
int tidx = 0;
// Main loop to read, modify, and write events
struct input_event ev;
while (tidx < EVENT_TIME_PAIR_CNT && read(fd_source, &ev, sizeof(ev)) > 0) {
struct timeval now;
gettimeofday(&now, NULL);
if (ev.type == EV_REL && (ev.code == 2 || ev.code == 3)) {
/* fprintf(stderr, "EVENT: type %d, code %d, value %d\n", ev.type,
* ev.code, */
/* ev.value); */
times[tidx++] = to_us(ev.time);
times[tidx++] = to_us(now);
times[tidx++] = ev.value;
}
}
// Cleanup
close(fd_source);
tidx = 0;
printf("event_time,read_time,naive_diff,extra_lag,diff\n"); // eve'ry is in us
while (tidx < EVENT_TIME_PAIR_CNT) {
__suseconds_t event_time = times[tidx++];
__suseconds_t read_time = times[tidx++];
__suseconds_t extra_lag_measured_by_input_handler = times[tidx++];
__suseconds_t diff = read_time - event_time;
printf("%lu,%lu,%lu,%lu,%lu\n", event_time, read_time, diff,
extra_lag_measured_by_input_handler,
diff + extra_lag_measured_by_input_handler);
}
return 0;
}
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
control_data = pd.read_csv("control.csv")
new_data = pd.read_csv("input_handler.csv")
fig, ax = plt.subplots()
ax.plot(np.arange(1000), control_data["diff"], 'b',
label=f"Hid-generic (mean = {control_data["diff"].mean()}us)")
ax.plot(np.arange(1000), new_data["diff"], 'g',
label=f"New driver (mean = {new_data["diff"].mean()}us)")
plt.ylabel('lag (us)')
plt.xlabel('reads')
legend = ax.legend(loc='upper center', fontsize='x-large')
plt.show()
""" Some extra data points out of curiosity """
virtual_minus_source = new_data["virtual_event_time"] - new_data["event_time"]
print("average lag between source and virtual device:",
virtual_minus_source.mean())
new_data["read_minus_virtual"] = new_data["read_time"] - \
new_data["virtual_event_time"]
print("average lag between virtual device and read:",
new_data["read_minus_virtual"].mean())
+11
View File
@@ -0,0 +1,11 @@
contourpy==1.2.1
cycler==0.12.1
fonttools==4.53.1
kiwisolver==1.4.5
matplotlib==3.9.1.post1
numpy==2.0.1
packaging==24.1
pillow==10.4.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
six==1.16.0