Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
fdfbb751
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
9 个月 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
fdfbb751
编写于
6月 20, 2023
作者:
O
openharmony_ci
提交者:
Gitee
6月 20, 2023
浏览文件
操作
浏览文件
下载
差异文件
!942 Add some testcase to benchark
Merge pull request !942 from qijinquan/benchmark
上级
c66d6344
08cefcb5
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
292 addition
and
1 deletion
+292
-1
Benchmark/libc_locale.cpp
Benchmark/libc_locale.cpp
+16
-0
Benchmark/libc_mman.cpp
Benchmark/libc_mman.cpp
+19
-0
Benchmark/libc_network.cpp
Benchmark/libc_network.cpp
+8
-0
Benchmark/libc_pthread.cpp
Benchmark/libc_pthread.cpp
+66
-1
Benchmark/libc_stdio.cpp
Benchmark/libc_stdio.cpp
+43
-0
Benchmark/libc_stdlib.cpp
Benchmark/libc_stdlib.cpp
+25
-0
Benchmark/libc_string.cpp
Benchmark/libc_string.cpp
+49
-0
Benchmark/libc_time.cpp
Benchmark/libc_time.cpp
+66
-0
未找到文件。
Benchmark/libc_locale.cpp
浏览文件 @
fdfbb751
...
...
@@ -16,6 +16,7 @@
#ifdef ONO_CURRENT_INTERFACE
#include <benchmark/benchmark.h>
#include <locale.h>
#include <langinfo.h>
#include "sys/types.h"
#include "sys/epoll.h"
#include "sys/stat.h"
...
...
@@ -82,10 +83,25 @@ static void Bm_function_Setlocale_Time(benchmark::State &state)
state
.
SetBytesProcessed
(
state
.
iterations
());
}
static
void
Bm_function_Locale_nl_langinfo
(
benchmark
::
State
&
state
)
{
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
nl_langinfo
(
CODESET
));
}
}
static
void
Bm_function_Locale_localeconv
(
benchmark
::
State
&
state
)
{
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
localeconv
());
}
}
MUSL_BENCHMARK
(
Bm_function_Setlocale_All
);
MUSL_BENCHMARK
(
Bm_function_Setlocale_All1
);
MUSL_BENCHMARK
(
Bm_function_Setlocale_All2
);
MUSL_BENCHMARK
(
Bm_function_Setlocale_Collate
);
MUSL_BENCHMARK
(
Bm_function_Setlocale_Ctype
);
MUSL_BENCHMARK
(
Bm_function_Setlocale_Time
);
MUSL_BENCHMARK
(
Bm_function_Locale_nl_langinfo
);
MUSL_BENCHMARK
(
Bm_function_Locale_localeconv
);
#endif
Benchmark/libc_mman.cpp
浏览文件 @
fdfbb751
...
...
@@ -134,9 +134,28 @@ static void Bm_function_Mmap_anonymous(benchmark::State &state)
state
.
SetItemsProcessed
(
state
.
iterations
());
}
static
void
Bm_function_Madvise
(
benchmark
::
State
&
state
)
{
int
fd
=
open
(
"/data/data/my_mmap_anonymous.txt"
,
O_RDWR
|
O_CREAT
);
if
(
fd
==
-
1
)
{
perror
(
"open anonymous mmap"
);
exit
(
EXIT_FAILURE
);
}
size_t
length
=
state
.
range
(
0
);
int
*
addr
=
(
int
*
)
mmap
(
NULL
,
length
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
|
MAP_ANONYMOUS
,
-
1
,
0
);
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
madvise
(
addr
,
length
,
0
));
}
munmap
(
addr
,
length
);
close
(
fd
);
remove
(
"/data/data/my_mmap_anonymous.txt"
);
state
.
SetItemsProcessed
(
state
.
iterations
());
}
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Mmap_1
,
"MMAP_SIZE"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Mmap_2
,
"MMAP_SIZE"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Mmap_3
,
"MMAP_SIZE"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Munmap
,
"MMAP_SIZE"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Mmap_anonymous
,
"MMAP_SIZE"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Madvise
,
"MMAP_SIZE"
);
#endif
\ No newline at end of file
Benchmark/libc_network.cpp
浏览文件 @
fdfbb751
...
...
@@ -54,6 +54,14 @@ static void Bm_function_Getaddrinfo_intranet1(benchmark::State &state)
state
.
SetBytesProcessed
(
state
.
iterations
());
}
static
void
Bm_function_Network_ntohs
(
benchmark
::
State
&
state
)
{
uint16_t
srcPort
=
5060
;
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
ntohs
(
srcPort
));
}
}
MUSL_BENCHMARK
(
Bm_function_Getaddrinfo_external_network
);
MUSL_BENCHMARK
(
Bm_function_Getaddrinfo_intranet1
);
MUSL_BENCHMARK
(
Bm_function_Network_ntohs
);
#endif
\ No newline at end of file
Benchmark/libc_pthread.cpp
浏览文件 @
fdfbb751
...
...
@@ -15,12 +15,23 @@
#ifdef ONO_CURRENT_INTERFACE
#include <benchmark/benchmark.h>
#include "pthread.h"
#include "semaphore.h"
#include "signal.h"
#include "threads.h"
#include "unistd.h"
#include "util.h"
static
void
Bm_function_pthread_mutexattr_settype
(
benchmark
::
State
&
state
)
{
pthread_mutexattr_t
mutex_attr
;
pthread_mutexattr_init
(
&
mutex_attr
);
while
(
state
.
KeepRunning
())
{
benchmark
::
DoNotOptimize
(
pthread_mutexattr_settype
(
&
mutex_attr
,
PTHREAD_MUTEX_NORMAL
));
}
pthread_mutexattr_destroy
(
&
mutex_attr
);
}
static
void
Bm_function_pthread_mutex_trylock_fast
(
benchmark
::
State
&
state
)
{
pthread_mutexattr_t
mutex_attr
;
...
...
@@ -375,6 +386,58 @@ static void Bm_function_pthread_cond_broadcast(benchmark::State &state)
state
.
SetBytesProcessed
(
state
.
iterations
());
}
static
void
Bm_function_Sem_timewait
(
benchmark
::
State
&
state
)
{
sem_t
semp
;
sem_init
(
&
semp
,
0
,
1
);
struct
timespec
spec
;
spec
.
tv_sec
=
0
;
spec
.
tv_nsec
=
5
;
while
(
state
.
KeepRunning
())
{
sem_timedwait
(
&
semp
,
&
spec
);
}
sem_destroy
(
&
semp
);
}
static
void
Bm_function_Sem_post_wait
(
benchmark
::
State
&
state
)
{
sem_t
semp
;
sem_init
(
&
semp
,
0
,
0
);
struct
timespec
spec
;
spec
.
tv_sec
=
0
;
spec
.
tv_nsec
=
5
;
while
(
state
.
KeepRunning
())
{
sem_post
(
&
semp
);
sem_wait
(
&
semp
);
}
sem_destroy
(
&
semp
);
}
static
void
Bm_function_pthread_cond_signal
(
benchmark
::
State
&
state
)
{
pthread_cond_t
cond
;
pthread_cond_init
(
&
cond
,
NULL
);
while
(
state
.
KeepRunning
())
{
pthread_cond_signal
(
&
cond
);
}
pthread_cond_destroy
(
&
cond
);
state
.
SetBytesProcessed
(
state
.
iterations
());
}
static
void
Bm_function_Sigaddset
(
benchmark
::
State
&
state
)
{
sigset_t
set
;
sigemptyset
(
&
set
);
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
sigaddset
(
&
set
,
SIGUSR1
));
}
state
.
SetBytesProcessed
(
state
.
iterations
());
}
MUSL_BENCHMARK
(
Bm_function_Sigaddset
);
MUSL_BENCHMARK
(
Bm_function_pthread_cond_signal
);
MUSL_BENCHMARK
(
Bm_function_pthread_mutexattr_settype
);
MUSL_BENCHMARK
(
Bm_function_pthread_mutex_trylock_fast
);
MUSL_BENCHMARK
(
Bm_function_pthread_mutex_trylock_errchk
);
MUSL_BENCHMARK
(
Bm_function_pthread_mutex_trylock_rec
);
...
...
@@ -396,4 +459,6 @@ MUSL_BENCHMARK(Bm_function_pthread_rwlock_timedrdlock);
MUSL_BENCHMARK
(
Bm_function_pthread_rwlock_timedwrlock
);
MUSL_BENCHMARK
(
Bm_function_pthread_cond_timedwait
);
MUSL_BENCHMARK
(
Bm_function_pthread_cond_broadcast
);
MUSL_BENCHMARK
(
Bm_function_Sem_timewait
);
MUSL_BENCHMARK
(
Bm_function_Sem_post_wait
);
#endif
\ No newline at end of file
Benchmark/libc_stdio.cpp
浏览文件 @
fdfbb751
...
...
@@ -1175,6 +1175,46 @@ static void Bm_function_Vfscanf_lluformat(benchmark::State &state)
state
.
SetBytesProcessed
(
state
.
iterations
());
}
static
void
Bm_function_Fileno_unlocked
(
benchmark
::
State
&
state
)
{
FILE
*
stream
=
fopen
(
"/data/data/vfscanf_lluformat.txt"
,
"w+"
);
if
(
stream
==
nullptr
)
{
perror
(
"fopen vfscanf lluformat"
);
exit
(
EXIT_FAILURE
);
}
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
fileno_unlocked
(
stream
));
}
fclose
(
stream
);
remove
(
"/data/data/vfscanf_lluformat.txt"
);
state
.
SetBytesProcessed
(
state
.
iterations
());
}
static
void
Bm_function_Fseek_fflush
(
benchmark
::
State
&
state
)
{
FILE
*
f
=
fopen
(
"/dev/zero"
,
"r"
);
if
(
f
==
nullptr
)
{
perror
(
"fopen fseek set"
);
exit
(
EXIT_FAILURE
);
}
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
fflush
(
f
));
}
fclose
(
f
);
state
.
SetItemsProcessed
(
state
.
iterations
());
}
static
void
Bm_function_Sscanf_vsscanf_int
(
benchmark
::
State
&
state
)
{
for
(
auto
_
:
state
)
{
va_list
ap
;
benchmark
::
DoNotOptimize
(
vsscanf
(
"20230515"
,
"%04d%02d%02d"
,
ap
));
}
state
.
SetBytesProcessed
(
state
.
iterations
());
}
MUSL_BENCHMARK
(
Bm_function_Fopen_read
);
MUSL_BENCHMARK
(
Bm_function_Fopen_write
);
MUSL_BENCHMARK
(
Bm_function_Fopen_append
);
...
...
@@ -1247,4 +1287,7 @@ MUSL_BENCHMARK(Bm_function_Vfscanf_hhxformat);
MUSL_BENCHMARK
(
Bm_function_Vfscanf_llxformat
);
MUSL_BENCHMARK
(
Bm_function_Vfscanf_lldformat
);
MUSL_BENCHMARK
(
Bm_function_Vfscanf_lluformat
);
MUSL_BENCHMARK
(
Bm_function_Fileno_unlocked
);
MUSL_BENCHMARK
(
Bm_function_Fseek_fflush
);
MUSL_BENCHMARK
(
Bm_function_Sscanf_vsscanf_int
);
#endif
\ No newline at end of file
Benchmark/libc_stdlib.cpp
浏览文件 @
fdfbb751
...
...
@@ -48,6 +48,29 @@ static void Bm_function_Strtod(benchmark::State &state)
}
}
static
void
Bm_function_Strtof
(
benchmark
::
State
&
state
)
{
const
char
*
var
[]
=
{
"+2.86500000e+01"
,
"3.1415"
,
"29"
,
"-123.456"
,
"1.23e5"
,
"0x1.2p3"
,
"-inf"
,
"123foo"
};
const
char
*
str
=
var
[
state
.
range
(
0
)];
char
*
ptr
;
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
strtof
(
str
,
&
ptr
));
}
}
static
void
Bm_function_Strtold
(
benchmark
::
State
&
state
)
{
const
char
*
var
[]
=
{
"+2.86500000e+01"
,
"3.1415"
,
"29"
,
"-123.456"
,
"1.23e5"
,
"0x1.2p3"
,
"-inf"
,
"123foo"
};
const
char
*
str
=
var
[
state
.
range
(
0
)];
char
*
ptr
;
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
strtold
(
str
,
&
ptr
));
}
}
// Used to sort elements in an array
static
void
Bm_function_Qsort
(
benchmark
::
State
&
state
)
{
...
...
@@ -107,6 +130,8 @@ static void Bm_function_Realpath(benchmark::State &state)
}
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Strtod
,
"BENCHMARK_VARIABLE"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Strtof
,
"BENCHMARK_VARIABLE"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Strtold
,
"BENCHMARK_VARIABLE"
);
MUSL_BENCHMARK
(
Bm_function_Qsort
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Realpath
,
"REALPATH_VARIABLE"
);
#endif
...
...
Benchmark/libc_string.cpp
浏览文件 @
fdfbb751
...
...
@@ -258,6 +258,52 @@ static void Bm_function_Strcasecmp(benchmark::State &state)
state
.
SetBytesProcessed
(
uint64_t
(
state
.
iterations
())
*
uint64_t
(
nbytes
));
}
static
void
Bm_function_Strncasecmp
(
benchmark
::
State
&
state
)
{
const
size_t
nbytes
=
state
.
range
(
0
);
const
size_t
haystackAlignment
=
state
.
range
(
1
);
const
size_t
needleAlignment
=
state
.
range
(
2
);
std
::
vector
<
char
>
haystack
;
std
::
vector
<
char
>
needle
;
char
*
haystackAligned
=
GetAlignedPtrFilled
(
&
haystack
,
haystackAlignment
,
nbytes
,
'x'
);
char
*
needleAligned
=
GetAlignedPtrFilled
(
&
needle
,
needleAlignment
,
nbytes
,
'x'
);
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
strncasecmp
(
haystackAligned
,
needleAligned
,
nbytes
));
}
state
.
SetBytesProcessed
(
uint64_t
(
state
.
iterations
())
*
uint64_t
(
nbytes
));
}
static
void
Bm_function_Strdup
(
benchmark
::
State
&
state
)
{
const
size_t
nbytes
=
state
.
range
(
0
);
const
size_t
haystackAlignment
=
state
.
range
(
1
);
std
::
vector
<
char
>
haystack
;
char
*
haystackAligned
=
GetAlignedPtrFilled
(
&
haystack
,
haystackAlignment
,
nbytes
,
'x'
);
haystackAligned
[
nbytes
-
1
]
=
'\0'
;
char
*
ptr
=
0
;
while
(
state
.
KeepRunning
())
{
benchmark
::
DoNotOptimize
(
ptr
=
strdup
(
haystackAligned
));
free
(
ptr
);
}
state
.
SetBytesProcessed
(
uint64_t
(
state
.
iterations
())
*
uint64_t
(
nbytes
));
}
static
void
Bm_function_Strncat
(
benchmark
::
State
&
state
)
{
const
size_t
nbytes
=
state
.
range
(
0
);
const
size_t
haystackAlignment
=
state
.
range
(
1
);
std
::
vector
<
char
>
haystack
;
char
*
haystackAligned
=
GetAlignedPtrFilled
(
&
haystack
,
haystackAlignment
,
nbytes
,
'x'
);
haystackAligned
[
nbytes
-
1
]
=
'\0'
;
std
::
vector
<
char
>
dstStack
;
char
*
dst
=
GetAlignedPtrFilled
(
&
dstStack
,
haystackAlignment
,
nbytes
,
'0'
);
while
(
state
.
KeepRunning
())
{
dst
[
0
]
=
0
;
benchmark
::
DoNotOptimize
(
strncat
(
dst
,
haystackAligned
,
nbytes
));
}
state
.
SetBytesProcessed
(
uint64_t
(
state
.
iterations
())
*
uint64_t
(
nbytes
));
}
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Memchr
,
"STRING_LIMIT"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Strnlen
,
"STRING_LIMIT"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Stpncpy
,
"STRING_LIMIT"
);
...
...
@@ -270,6 +316,9 @@ MUSL_BENCHMARK(Bm_function_Strcasecmp_small_equal);
MUSL_BENCHMARK
(
Bm_function_Strcasecmp_equal
);
MUSL_BENCHMARK
(
Bm_function_Strcasecmp_not_equal
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Strcasecmp
,
"ALIGNED_TWOBUF"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Strncasecmp
,
"ALIGNED_TWOBUF"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Strdup
,
"ALIGNED_ONEBUF"
);
MUSL_BENCHMARK_WITH_ARG
(
Bm_function_Strncat
,
"ALIGNED_ONEBUF"
);
#ifdef ONO_CURRENT_INTERFACE
MUSL_BENCHMARK
(
Bm_function_Strrchr
);
...
...
Benchmark/libc_time.cpp
浏览文件 @
fdfbb751
...
...
@@ -55,9 +55,75 @@ static void Bm_function_Tzset(benchmark::State &state)
tzset
();
}
}
static
void
Bm_function_Clock_nanosleep_realtime
(
benchmark
::
State
&
state
)
{
struct
timespec
req
,
rem
;
req
.
tv_nsec
=
10
;
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
clock_nanosleep
(
CLOCK_REALTIME
,
0
,
&
req
,
&
rem
));
}
}
static
void
Bm_function_Clock_nanosleep_realtime_raw
(
benchmark
::
State
&
state
)
{
struct
timespec
req
,
rem
;
req
.
tv_nsec
=
10
;
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
clock_nanosleep
(
CLOCK_REALTIME_COARSE
,
0
,
&
req
,
&
rem
));
}
}
static
void
Bm_function_Clock_nanosleep_realtime_coarse
(
benchmark
::
State
&
state
)
{
struct
timespec
req
,
rem
;
req
.
tv_nsec
=
10
;
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
clock_nanosleep
(
CLOCK_REALTIME_COARSE
,
0
,
&
req
,
&
rem
));
}
}
static
void
Bm_function_Clock_nanosleep_monotonic
(
benchmark
::
State
&
state
)
{
struct
timespec
req
,
rem
;
req
.
tv_nsec
=
10
;
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
clock_nanosleep
(
CLOCK_MONOTONIC
,
0
,
&
req
,
&
rem
));
}
}
static
void
Bm_function_Clock_nanosleep_monotonic_coarse
(
benchmark
::
State
&
state
)
{
struct
timespec
req
,
rem
;
req
.
tv_nsec
=
10
;
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
clock_nanosleep
(
CLOCK_MONOTONIC_COARSE
,
0
,
&
req
,
&
rem
));
}
}
static
void
Bm_function_Clock_nanosleep_monotonic_raw
(
benchmark
::
State
&
state
)
{
struct
timespec
req
,
rem
;
req
.
tv_nsec
=
10
;
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
clock_nanosleep
(
CLOCK_MONOTONIC_RAW
,
0
,
&
req
,
&
rem
));
}
}
static
void
Bm_function_Clock_nanosleep_boottime
(
benchmark
::
State
&
state
)
{
struct
timespec
req
,
rem
;
req
.
tv_nsec
=
10
;
for
(
auto
_
:
state
)
{
benchmark
::
DoNotOptimize
(
clock_nanosleep
(
CLOCK_BOOTTIME
,
0
,
&
req
,
&
rem
));
}
}
MUSL_BENCHMARK
(
Bm_function_Nanosleep_0ns
);
MUSL_BENCHMARK
(
Bm_function_Nanosleep_10ns
);
MUSL_BENCHMARK
(
Bm_function_Nanosleep_100ns
);
MUSL_BENCHMARK
(
Bm_function_Tzset
);
MUSL_BENCHMARK
(
Bm_function_Clock_nanosleep_realtime
);
MUSL_BENCHMARK
(
Bm_function_Clock_nanosleep_realtime_raw
);
MUSL_BENCHMARK
(
Bm_function_Clock_nanosleep_realtime_coarse
);
MUSL_BENCHMARK
(
Bm_function_Clock_nanosleep_monotonic
);
MUSL_BENCHMARK
(
Bm_function_Clock_nanosleep_monotonic_raw
);
MUSL_BENCHMARK
(
Bm_function_Clock_nanosleep_monotonic_coarse
);
MUSL_BENCHMARK
(
Bm_function_Clock_nanosleep_boottime
);
#endif
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录