aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/liburing/test/helpers.c
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2024-11-09 19:14:48 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2024-11-09 19:25:43 +0300
commit9ade466e8683a2e3b45dacf45f74fcf4a3c40cee (patch)
tree5386d43454d677cb1239ed7a889dfcf101e99136 /contrib/libs/liburing/test/helpers.c
parent1f59ab019232ff97a73c7c13736b254925fa8b0b (diff)
downloadydb-9ade466e8683a2e3b45dacf45f74fcf4a3c40cee.tar.gz
Update contrib/libs/liburing to 2.8
commit_hash:761e2e80642a3d32073f0261b3f5b1992e54a74f
Diffstat (limited to 'contrib/libs/liburing/test/helpers.c')
-rw-r--r--contrib/libs/liburing/test/helpers.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/contrib/libs/liburing/test/helpers.c b/contrib/libs/liburing/test/helpers.c
index 0d897271d8..2f09df4f23 100644
--- a/contrib/libs/liburing/test/helpers.c
+++ b/contrib/libs/liburing/test/helpers.c
@@ -317,3 +317,50 @@ void t_error(int status, int errnum, const char *format, ...)
va_end(args);
exit(status);
}
+
+unsigned long long mtime_since(const struct timeval *s, const struct timeval *e)
+{
+ long long sec, usec;
+
+ sec = e->tv_sec - s->tv_sec;
+ usec = (e->tv_usec - s->tv_usec);
+ if (sec > 0 && usec < 0) {
+ sec--;
+ usec += 1000000;
+ }
+
+ sec *= 1000;
+ usec /= 1000;
+ return sec + usec;
+}
+
+unsigned long long mtime_since_now(struct timeval *tv)
+{
+ struct timeval end;
+
+ gettimeofday(&end, NULL);
+ return mtime_since(tv, &end);
+}
+
+unsigned long long utime_since(const struct timeval *s, const struct timeval *e)
+{
+ long long sec, usec;
+
+ sec = e->tv_sec - s->tv_sec;
+ usec = (e->tv_usec - s->tv_usec);
+ if (sec > 0 && usec < 0) {
+ sec--;
+ usec += 1000000;
+ }
+
+ sec *= 1000000;
+ return sec + usec;
+}
+
+unsigned long long utime_since_now(struct timeval *tv)
+{
+ struct timeval end;
+
+ gettimeofday(&end, NULL);
+ return utime_since(tv, &end);
+}