butcher fixedbenchmark to find a bug.

This commit is contained in:
Wolfgang Thaller 2014-09-23 09:12:52 +02:00
parent c31479ee7e
commit cf2a08b7de
2 changed files with 35 additions and 27 deletions

View File

@ -18,7 +18,7 @@
cmake_minimum_required(VERSION 2.8)
if(NOT APPLE)
set(CMAKE_CXX_FLAGS "-std=c++11 -fno-threadsafe-statics -g -fomit-frame-pointer") # -mcpu=68040")
set(CMAKE_CXX_FLAGS "-std=c++11 -fno-threadsafe-statics -fomit-frame-pointer -O0 -fno-exceptions") # -mcpu=68040")
endif()
include_directories(../App2)
@ -35,8 +35,8 @@ if(APPLE)
target_link_libraries(Raytracer "-framework Carbon")
target_link_libraries(Raytracer2 "-framework Carbon")
else()
add_executable(FixedBenchmark fixedbenchmark.cc fixed.h fixed.cc)
target_link_libraries(FixedBenchmark RetroConsole retrocrt)
add_executable(FixedBenchmark fixedbenchmark.cc fixed.h )
target_link_libraries(FixedBenchmark retrocrt) #RetroConsole
add_custom_command(
OUTPUT FixedBenchmark.bin
COMMAND ${MAKE_APPL} -c FixedBenchmark -o FixedBenchmark

View File

@ -24,7 +24,7 @@
#include <Events.h>
#include "fixed.h"
//#include "fixed.h"
#include <cmath>
using std::sqrt;
@ -43,40 +43,44 @@ void runTests(std::string type, std::vector<number>& numbers)
std::cout << "***********************************\n";
std::cout << "Running tests on type " << type << ":\n";
std::cout << "***********************************\n";
Debugger();
int n = numbers.size();
std::vector<number> outputs(n);
std::vector<float> outputs(n);
Debugger();
std::cout << "Testing Multiplication..." << std::flush;
{
timer t;
for(int i = 0; i < n; i++)
/* for(int i = 0; i < n; i++)
{
outputs[i] = numbers[i] * numbers[n - i - 1];
}
}*/
std::cout << 1000 * t.elapsed() / n << "ms\n";
}
Debugger();
std::cout << "Testing Division..." << std::flush;
{
timer t;
for(int i = 0; i < n; i++)
/* for(int i = 0; i < n; i++)
{
outputs[i] = numbers[i] / numbers[n - i - 1];
}
}*/
std::cout << 1000 * t.elapsed() / n << "ms\n";
}
Debugger();
std::cout << "Testing Square Root..." << std::flush;
{
timer t;
for(int i = 0; i < n; i++)
/* for(int i = 0; i < n; i++)
{
outputs[i] = sqrt(numbers[i]);
}
}*/
//Debugger();
std::cout << 1000 * t.elapsed() / n << "ms\n";
}
std::cout << std::endl;
Debugger();
//std::cout << std::endl;
}
int main(int argc, char** argv)
@ -86,26 +90,30 @@ int main(int argc, char** argv)
std::cout << "Generating numbers..." << std::flush;
const int n = 1000;
std::vector<fixed> numbers(n);
// std::vector<fixed> numbers(n);
std::vector<float> floats(n);
std::vector<double> doubles(n);
for(int i = 0; i < numbers.size(); i++)
// std::vector<double> doubles(n);
/*
for(int i = 0; i < n; i++)
{
numbers[i] = fixed(std::rand(), fixed::raw());
// numbers[i] = fixed(std::rand(), fixed::raw());
floats[i] = float(std::rand()) / RAND_MAX;
doubles[i] = double(std::rand()) / RAND_MAX;
}
std::vector<fixed> outputs(n);
// doubles[i] = double(std::rand()) / RAND_MAX;
}*/
//std::vector<fixed> outputs(n);
std::cout << "done.\n\n";
runTests("float", floats);
runTests("double", doubles);
runTests("fixed", numbers);
Debugger();
runTests("float", floats);
Debugger();
/*runTests("double", doubles);
runTests("fixed", numbers);*/
/*
std::cout << "Press Enter to Exit ;-)\n";
std::cin.get();
*/
return 0;
}