update benchmark

This commit is contained in:
kabeor 2022-01-04 23:44:22 +08:00
parent 5b073dbe60
commit 8ae012ab77
7 changed files with 51 additions and 14 deletions

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

Binary file not shown.

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()