Merge pull request #1812 from kabeor/next

update benchmark
This commit is contained in:
Wu ChenXu 2022-01-05 11:11:31 +08:00 committed by GitHub
commit 21aceb7da5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 17 deletions

4
.gitignore vendored
View File

@ -116,6 +116,7 @@ test_arm_regression
test_arm_regression.o
fuzz_harness
test_iter_benchmark
test_file_benchmark
fuzz_bindisasm
fuzz_disasm
fuzz_decode_platform
@ -129,6 +130,3 @@ cstool/cstool
# android
android-ndk-*
# benchmark/
benchmark/cs-benchmark*

View File

@ -1,7 +0,0 @@
# Modified from https://github.com/athre0z/disas-bench
all:
cc main.c -O3 -o cs-benchmark -I../include ../build/libcapstone.a
clean:
rm -f cs-benchmark* *.o

View File

@ -1,12 +1,17 @@
# Sample Makefile for Capstone Disassembly Engine
LIBNAME = capstone
LIBNAME = ../../build/libcapstone.a
test_iter_benchmark: test_iter_benchmark.o
${CC} $< -O3 -Wall -l$(LIBNAME) -o $@
all: test_iter_benchmark test_file_benchmark
%.o: %.c
${CC} -c -I../../include $< -o $@
test_iter_benchmark: test_iter_benchmark.c
${CC} $< -O3 -Wall -o $@ -I../../include $(LIBNAME)
test_file_benchmark: test_file_benchmark.c
${CC} $< -O3 -Wall -o $@ -I../../include $(LIBNAME)
# %.o: %.c
# ${CC} -c $< -o $@
clean:
rm -rf *.o test_iter_benchmark
rm -rf *.o test_iter_benchmark test_file_benchmark

39
suite/benchmark/README.md Normal file
View File

@ -0,0 +1,39 @@
# Benchmark
## Build capstone
```bash
mkdir build
cd build
cmake ..
#This last command is also where you can pass additional CMake configuration flags
#using `-D<key>=<value>`. Then to build use:
cmake --build . --config Release
cd ..
```
## Build benchmark
```bash
cd suite/benchmark
make
```
## test_iter_benchmark
```bash
./test_iter_benchmark
```
## test_file_benchmark
```bash
./test_file_benchmark
```
The optional `test_file_benchmark` arguments are:
- `[loop-count]` = optional loop count. Total number of bytes decoded and formatted is `<code-len> * [loop-count]`
- `<code-offset>` = offset of the code section (in decimal or 0x hex)
- `<code-len>` = length of the code section (in decimal or 0x hex)
- `<filename>` = 64-bit x86 binary file to decode and format

View File

@ -89,7 +89,7 @@ static void test()
cs_close(&handle);
end = clock();
timeUsed = (double)(end - start) / CLOCKS_PER_SEC;
printf("time used:%f\n", timeUsed);
printf("time used: %f s\n", timeUsed);
}
int main()