Skip to content

Commit

Permalink
add libinput startup test
Browse files Browse the repository at this point in the history
The goal of this new test is to check the startup time of libinput only.

Signed-off-by: Ludovic Desroches <[email protected]>
  • Loading branch information
ldesroches committed Apr 3, 2024
1 parent 2b64eb6 commit e306c51
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ AUTOMAKE_OPTIONS = subdir-objects
CUSTOM_CXXFLAGS = $(WARN_CFLAGS) \
-I$(top_srcdir)/src \
-I$(top_srcdir)/external/hayai/src \
$(LIBEGT_CFLAGS)
$(LIBEGT_CFLAGS) \
$(LIBINPUT_CFLAGS)

CUSTOM_LDADD = $(LIBEGT_LIBS)
CUSTOM_LDADD = $(LIBEGT_LIBS) $(LIBINPUT_LIBS) -ludev

bin_PROGRAMS = benchmark
benchmark_SOURCES = src/main.cpp
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ PKG_CHECK_MODULES(LIBEGT, [libegt >= 1.6], [], [
AC_MSG_ERROR(libegt not found. This is required.)
])

PKG_CHECK_MODULES(LIBINPUT, [libinput >= 1.6.3], [], [
AC_MSG_ERROR(libinput not found. This is required.)
])

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
36 changes: 36 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
#include <hayai_main.hpp>
#include <vector>

#include <libinput.h>
#include <libudev.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>

using namespace std;
using namespace egt;
using namespace egt::experimental;
Expand Down Expand Up @@ -324,6 +330,36 @@ BENCHMARK(Startup, Cairo, 10, 10)
cairo_destroy(cr);
}

int open_restricted(const char* path, int flags, void* user_data)
{
int fd = open(path, flags);
return fd < 0 ? -errno : fd;
}

void close_restricted(int fd, void* user_data)
{
close(fd);
}

struct libinput_interface interface =
{
open_restricted,
close_restricted,
};

BENCHMARK(Startup, Libinput, 10, 10)
{
struct libinput* li;
struct udev* udev = udev_new();

li = libinput_udev_create_context(&interface, NULL, udev);

libinput_udev_assign_seat(li, "seat0");

libinput_unref(li);
udev_unref(udev);
}

class InputFixture : public ::hayai::Fixture
{
public:
Expand Down

0 comments on commit e306c51

Please sign in to comment.