• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2020-2023. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "sys/eventfd.h"
17 #include "unistd.h"
18 #include "util.h"
19 
20 // Write a value to eventfd
Bm_function_eventfd_write(benchmark::State & state)21 static void Bm_function_eventfd_write(benchmark::State &state)
22 {
23     unsigned int initValue = 2;
24     int fd = eventfd(initValue, O_NONBLOCK);
25     if (fd == -1) {
26         perror("evevtfd eventfd_write");
27     }
28     for (auto _ : state) {
29         if (eventfd_write(fd, initValue + 1) != 0) {
30             perror("eventfd_write proc");
31         }
32     }
33     close(fd);
34 }
35 
36 MUSL_BENCHMARK(Bm_function_eventfd_write);