Compare commits
No commits in common. "57acc5e16f86aced2d54f1c3ba02bf253e9d6352" and "297d9c53f3d6323197bdc94873b0b88391fbcd1b" have entirely different histories.
57acc5e16f
...
297d9c53f3
@ -4,12 +4,6 @@ CC=clang
|
|||||||
CXX=clang++
|
CXX=clang++
|
||||||
CFLAGS="-Wall -Wextra -I$(realpath ./include) "
|
CFLAGS="-Wall -Wextra -I$(realpath ./include) "
|
||||||
|
|
||||||
ASM=nasm
|
|
||||||
ASM_FLAGS="-f elf64 "
|
|
||||||
|
|
||||||
AR=ar
|
|
||||||
AR_FLAGS="rcs"
|
|
||||||
|
|
||||||
# PARSE ARGUMENTS
|
# PARSE ARGUMENTS
|
||||||
# From this StackOverflow answer https://stackoverflow.com/a/14203146
|
# From this StackOverflow answer https://stackoverflow.com/a/14203146
|
||||||
while [[ $# > 0 ]];do
|
while [[ $# > 0 ]];do
|
||||||
@ -36,7 +30,7 @@ done
|
|||||||
|
|
||||||
# BUILD TYPE
|
# BUILD TYPE
|
||||||
if [[ $RELEASE == true ]]; then
|
if [[ $RELEASE == true ]]; then
|
||||||
CFLAGS+="-g -O1"
|
CFLAGS+="-O3"
|
||||||
else
|
else
|
||||||
CFLAGS+="-g"
|
CFLAGS+="-g"
|
||||||
fi
|
fi
|
||||||
@ -77,18 +71,6 @@ MEMTESTOUT=memtest
|
|||||||
(set -x ; $CC $CFLAGS $MEMTESTSRC -o $MEMTESTOUT)
|
(set -x ; $CC $CFLAGS $MEMTESTSRC -o $MEMTESTOUT)
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# REPTEST ASSEMBLY
|
|
||||||
ASM_BUILD_DIR=reptest_build
|
|
||||||
ASM_SRC="./src/repetition_testing/reptest_functions.asm"
|
|
||||||
ASM_OBJ="./$ASM_BUILD_DIR/funcs.o"
|
|
||||||
ASM_LIB="./$ASM_BUILD_DIR/libfuncs.a"
|
|
||||||
|
|
||||||
mkdir $ASM_BUILD_DIR
|
|
||||||
|
|
||||||
(set -x ; $ASM $ASM_FLAGS $ASM_SRC -o $ASM_OBJ)
|
|
||||||
(set -x ; $AR $AR_FLAGS $ASM_LIB $ASM_OBJ)
|
|
||||||
echo
|
|
||||||
|
|
||||||
if [[ $BASIC_PROFILING == true ]] || [[ $FULL_PROFILING == true ]]; then
|
if [[ $BASIC_PROFILING == true ]] || [[ $FULL_PROFILING == true ]]; then
|
||||||
if [[ $FULL_PROFILING == true ]]; then
|
if [[ $FULL_PROFILING == true ]]; then
|
||||||
JSONFLAGS+="-DFULL_PROFILING"
|
JSONFLAGS+="-DFULL_PROFILING"
|
||||||
@ -113,7 +95,7 @@ if [[ $BASIC_PROFILING == true ]] || [[ $FULL_PROFILING == true ]]; then
|
|||||||
cd ../
|
cd ../
|
||||||
|
|
||||||
# REPETITION TESTING
|
# REPETITION TESTING
|
||||||
REPTESTSRC="./src/repetition_testing/*.cpp ./$PROF_BUILD_DIR/*.o $ASM_LIB"
|
REPTESTSRC="./src/repetition_testing/*.cpp ./$PROF_BUILD_DIR/*.o"
|
||||||
REPTESTOUT=reptest
|
REPTESTOUT=reptest
|
||||||
|
|
||||||
(set -x ; $CXX $CFLAGS $REPTESTFLAGS $REPTESTSRC -o $REPTESTOUT)
|
(set -x ; $CXX $CFLAGS $REPTESTFLAGS $REPTESTSRC -o $REPTESTOUT)
|
||||||
@ -132,4 +114,4 @@ cd ../
|
|||||||
echo
|
echo
|
||||||
|
|
||||||
# CLEAR BUILD FILES
|
# CLEAR BUILD FILES
|
||||||
rm -rvf $JSON_BUILD_DIR $PROF_BUILD_DIR $ASM_BUILD_DIR
|
rm -rvf $JSON_BUILD_DIR $PROF_BUILD_DIR
|
||||||
|
@ -9,18 +9,9 @@
|
|||||||
|
|
||||||
#define ARR_LEN(ARR) sizeof(ARR) / sizeof(*ARR)
|
#define ARR_LEN(ARR) sizeof(ARR) / sizeof(*ARR)
|
||||||
|
|
||||||
extern "C" void mov_all_bytes_asm(char *buffer, u64 size);
|
|
||||||
extern "C" void nop_all_bytes_asm(u64 size);
|
|
||||||
extern "C" void inc_all_bytes_asm(u64 size);
|
|
||||||
extern "C" void dec_all_bytes_asm(u64 size);
|
|
||||||
|
|
||||||
void test_fread(reptester *tester, alloc_type type);
|
void test_fread(reptester *tester, alloc_type type);
|
||||||
void test_read(reptester *tester, alloc_type type);
|
void test_read(reptester *tester, alloc_type type);
|
||||||
void test_write(reptester *tester, alloc_type type);
|
void test_write(reptester *tester, alloc_type type);
|
||||||
void test_write_mov_all_bytes_asm(reptester *tester, alloc_type type);
|
|
||||||
void test_write_nop_all_bytes_asm(reptester *tester, alloc_type type);
|
|
||||||
void test_write_inc_all_bytes_asm(reptester *tester, alloc_type type);
|
|
||||||
void test_write_dec_all_bytes_asm(reptester *tester, alloc_type type);
|
|
||||||
u64 get_file_length(FILE *fp);
|
u64 get_file_length(FILE *fp);
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
@ -74,16 +65,8 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
func_data funcs[] = {
|
func_data funcs[] = {
|
||||||
{{"WRITE", "WRITE WITH MALLOC"}, test_write},
|
{{"WRITE", "WRITE WITH MALLOC"}, test_write},
|
||||||
{{"WRITE MOV ASM", "WRITE MOV ASM WITH MALLOC"},
|
{{"READ", "READ WITH MALLOC"}, test_read},
|
||||||
test_write_mov_all_bytes_asm},
|
{{"FREAD", "FREAD WITH MALLOC"}, test_fread},
|
||||||
{{"WRITE NOP ASM", "WRITE NOP ASM WITH MALLOC"},
|
|
||||||
test_write_nop_all_bytes_asm},
|
|
||||||
{{"WRITE INC ASM", "WRITE INC ASM WITH MALLOC"},
|
|
||||||
test_write_inc_all_bytes_asm},
|
|
||||||
{{"WRITE DEC ASM", "WRITE DEC ASM WITH MALLOC"},
|
|
||||||
test_write_dec_all_bytes_asm},
|
|
||||||
// {{"READ", "READ WITH MALLOC"}, test_read},
|
|
||||||
// {{"FREAD", "FREAD WITH MALLOC"}, test_fread},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
tester.params.read_size = get_file_length(fp);
|
tester.params.read_size = get_file_length(fp);
|
||||||
@ -172,12 +155,6 @@ void test_read(reptester *tester, alloc_type type) {
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_to_all_bytes(char *buffer, u64 size) {
|
|
||||||
for (u64 i = 0; i < size; ++i) {
|
|
||||||
buffer[i] = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_write(reptester *tester, alloc_type type) {
|
void test_write(reptester *tester, alloc_type type) {
|
||||||
u64 start = read_cpu_timer();
|
u64 start = read_cpu_timer();
|
||||||
u64 fault_count_start = page_fault_count();
|
u64 fault_count_start = page_fault_count();
|
||||||
@ -186,107 +163,9 @@ void test_write(reptester *tester, alloc_type type) {
|
|||||||
|
|
||||||
u64 total_size = tester->params.read_size * tester->params.read_count;
|
u64 total_size = tester->params.read_size * tester->params.read_count;
|
||||||
|
|
||||||
write_to_all_bytes(tester->params.buffer, total_size);
|
for (u64 i = 0; i < total_size; ++i) {
|
||||||
|
tester->params.buffer[i] = '0';
|
||||||
u64 fault_count_end = page_fault_count();
|
}
|
||||||
u64 end = read_cpu_timer();
|
|
||||||
|
|
||||||
u64 read_time = end - start;
|
|
||||||
u64 page_faults = fault_count_end - fault_count_start;
|
|
||||||
|
|
||||||
tester->results = {
|
|
||||||
total_size,
|
|
||||||
read_time,
|
|
||||||
page_faults,
|
|
||||||
};
|
|
||||||
|
|
||||||
handle_free(tester, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_write_mov_all_bytes_asm(reptester *tester, alloc_type type) {
|
|
||||||
u64 start = read_cpu_timer();
|
|
||||||
u64 fault_count_start = page_fault_count();
|
|
||||||
|
|
||||||
handle_alloc(tester, type);
|
|
||||||
|
|
||||||
u64 total_size = tester->params.read_size * tester->params.read_count;
|
|
||||||
|
|
||||||
mov_all_bytes_asm(tester->params.buffer, total_size);
|
|
||||||
|
|
||||||
u64 fault_count_end = page_fault_count();
|
|
||||||
u64 end = read_cpu_timer();
|
|
||||||
|
|
||||||
u64 read_time = end - start;
|
|
||||||
u64 page_faults = fault_count_end - fault_count_start;
|
|
||||||
|
|
||||||
tester->results = {
|
|
||||||
total_size,
|
|
||||||
read_time,
|
|
||||||
page_faults,
|
|
||||||
};
|
|
||||||
|
|
||||||
handle_free(tester, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_write_nop_all_bytes_asm(reptester *tester, alloc_type type) {
|
|
||||||
u64 start = read_cpu_timer();
|
|
||||||
u64 fault_count_start = page_fault_count();
|
|
||||||
|
|
||||||
handle_alloc(tester, type);
|
|
||||||
|
|
||||||
u64 total_size = tester->params.read_size * tester->params.read_count;
|
|
||||||
|
|
||||||
nop_all_bytes_asm(total_size);
|
|
||||||
|
|
||||||
u64 fault_count_end = page_fault_count();
|
|
||||||
u64 end = read_cpu_timer();
|
|
||||||
|
|
||||||
u64 read_time = end - start;
|
|
||||||
u64 page_faults = fault_count_end - fault_count_start;
|
|
||||||
|
|
||||||
tester->results = {
|
|
||||||
total_size,
|
|
||||||
read_time,
|
|
||||||
page_faults,
|
|
||||||
};
|
|
||||||
|
|
||||||
handle_free(tester, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_write_inc_all_bytes_asm(reptester *tester, alloc_type type) {
|
|
||||||
u64 start = read_cpu_timer();
|
|
||||||
u64 fault_count_start = page_fault_count();
|
|
||||||
|
|
||||||
handle_alloc(tester, type);
|
|
||||||
|
|
||||||
u64 total_size = tester->params.read_size * tester->params.read_count;
|
|
||||||
|
|
||||||
inc_all_bytes_asm(total_size);
|
|
||||||
|
|
||||||
u64 fault_count_end = page_fault_count();
|
|
||||||
u64 end = read_cpu_timer();
|
|
||||||
|
|
||||||
u64 read_time = end - start;
|
|
||||||
u64 page_faults = fault_count_end - fault_count_start;
|
|
||||||
|
|
||||||
tester->results = {
|
|
||||||
total_size,
|
|
||||||
read_time,
|
|
||||||
page_faults,
|
|
||||||
};
|
|
||||||
|
|
||||||
handle_free(tester, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_write_dec_all_bytes_asm(reptester *tester, alloc_type type) {
|
|
||||||
u64 start = read_cpu_timer();
|
|
||||||
u64 fault_count_start = page_fault_count();
|
|
||||||
|
|
||||||
handle_alloc(tester, type);
|
|
||||||
|
|
||||||
u64 total_size = tester->params.read_size * tester->params.read_count;
|
|
||||||
|
|
||||||
dec_all_bytes_asm(total_size);
|
|
||||||
|
|
||||||
u64 fault_count_end = page_fault_count();
|
u64 fault_count_end = page_fault_count();
|
||||||
u64 end = read_cpu_timer();
|
u64 end = read_cpu_timer();
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
global mov_all_bytes_asm
|
|
||||||
global nop_all_bytes_asm
|
|
||||||
global inc_all_bytes_asm
|
|
||||||
global dec_all_bytes_asm
|
|
||||||
|
|
||||||
mov_all_bytes_asm:
|
|
||||||
xor rax, rax
|
|
||||||
|
|
||||||
.loop:
|
|
||||||
mov BYTE [rdi + rax * 1], al
|
|
||||||
inc rax
|
|
||||||
cmp rsi, rax
|
|
||||||
jne .loop
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
nop_all_bytes_asm:
|
|
||||||
xor rax, rax
|
|
||||||
|
|
||||||
.loop:
|
|
||||||
db 0x0f, 0x1f, 0x00
|
|
||||||
inc rax
|
|
||||||
cmp rdi, rax
|
|
||||||
jne .loop
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
inc_all_bytes_asm:
|
|
||||||
xor rax, rax
|
|
||||||
|
|
||||||
.loop:
|
|
||||||
inc rax
|
|
||||||
cmp rdi, rax
|
|
||||||
jne .loop
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
dec_all_bytes_asm:
|
|
||||||
.loop:
|
|
||||||
dec rdi
|
|
||||||
jnz .loop
|
|
||||||
|
|
||||||
ret
|
|
Loading…
x
Reference in New Issue
Block a user