Prepare a benchmark program

This commit is contained in:
Baptiste Wicht 2016-08-08 23:00:20 +02:00
parent a6ef114dca
commit f0f0508910
3 changed files with 46 additions and 1 deletions

View File

@ -2,7 +2,7 @@
include ../cpp.mk
PROGRAMS=long loop longone longtwo keyboard tsh cpuid shutdown reboot args stat cat which readelf touch mkdir rm date ls lspci lse820 mount df uptime writer divzero odin ps
PROGRAMS=long loop longone longtwo keyboard tsh cpuid shutdown reboot args stat cat which readelf touch mkdir rm date ls lspci lse820 mount df uptime writer divzero odin ps bench
default: dist

14
programs/bench/Makefile Normal file
View File

@ -0,0 +1,14 @@
.PHONY: default clean
EXEC_NAME=bench
default: link
include ../../cpp.mk
$(eval $(call program_compile_cpp_folder,src))
$(eval $(call program_link_executable,$(EXEC_NAME)))
clean:
@ echo -e "Remove compiled files"
@ rm -rf debug

View File

@ -0,0 +1,31 @@
//=======================================================================
// Copyright Baptiste Wicht 2013-2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
#include <print.hpp>
#include <system.hpp>
#include <datetime.hpp>
constexpr const size_t PAGES = 256;
//TODO Need a ms timestamp at least
int main(){
char* buffer_one = new char[PAGES * 4096];
char* buffer_two = new char[PAGES * 4096];
auto date = local_date();
auto start = date.hour * 3600 + date.minutes * 60 + date.seconds;
std::copy_n(buffer_one, buffer_two, PAGES * 4096);
date = local_date();
auto end = date.hour * 3600 + date.minutes * 60 + date.seconds;
printf("Copy took %u \n", end - start);
exit(0);
}