Skip to content

Commit

Permalink
rename to syscall
Browse files Browse the repository at this point in the history
  • Loading branch information
firedtoad committed Jun 29, 2023
1 parent 624caf9 commit 8de59b1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ add_subdirectory(src/mutex)
add_subdirectory(src/random)
add_subdirectory(src/timer)
add_subdirectory(src/ub)
add_subdirectory(src/vsdo)
add_subdirectory(src/syscall)
1 change: 1 addition & 0 deletions src/vsdo/CMakeLists.txt → src/syscall/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_executable(vdso vdso.cpp)
add_executable(epoll epoll.cpp)
#target_link_options(vdso PRIVATE -static -Wl,-Bdynamic)
#target_compile_options(vdso PRIVATE -static)
45 changes: 45 additions & 0 deletions src/syscall/epoll.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2023 The Division Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author dietoad@gmail.com && firedtoad@gmail.com

#include <benchmark/benchmark.h>
#include <fcntl.h>
#include <sys/epoll.h>
#include <unistd.h>

template <size_t wait> static void BenchEpollWait(benchmark::State &state)
{
int efd = epoll_create1(EPOLL_CLOEXEC);
epoll_event events[1024];
int fd = open("/proc/stat", 0);
epoll_event evt;
evt.events = EPOLLIN;
epoll_ctl(efd, EPOLL_CTL_ADD, fd, &evt);
for (auto _ : state)
{
int r = epoll_wait(efd, events, 1024, wait);
benchmark::DoNotOptimize(r);
}
close(fd);
close(efd);
}
BENCHMARK_TEMPLATE(BenchEpollWait, 1);
BENCHMARK_TEMPLATE(BenchEpollWait, 0);

int main(int argc, char **argv)
{
benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
return 0;
}
File renamed without changes.

0 comments on commit 8de59b1

Please sign in to comment.