Revert "butcher fixedbenchmark to find a bug."

This reverts commit 163ec2bb26958199549716d45297b1e427d6b0bd.
This commit is contained in:
Wolfgang Thaller 2014-09-23 23:48:41 +02:00
parent 1de00c3f09
commit 366768b135
2 changed files with 26 additions and 34 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 -fomit-frame-pointer -O0 -fno-exceptions") # -mcpu=68040")
set(CMAKE_CXX_FLAGS "-std=c++11 -fno-threadsafe-statics -g -fomit-frame-pointer") # -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 )
target_link_libraries(FixedBenchmark retrocrt) #RetroConsole
add_executable(FixedBenchmark fixedbenchmark.cc fixed.h fixed.cc)
target_link_libraries(FixedBenchmark RetroConsole retrocrt)
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,44 +43,40 @@ 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<float> outputs(n);
Debugger();
std::vector<number> outputs(n);
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";
}
Debugger();
//std::cout << std::endl;
std::cout << std::endl;
}
int main(int argc, char** argv)
@ -90,30 +86,26 @@ 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 < n; i++)
std::vector<double> doubles(n);
for(int i = 0; i < numbers.size(); 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";
Debugger();
runTests("float", floats);
Debugger();
runTests("double", doubles);
runTests("fixed", numbers);
/*runTests("double", doubles);
runTests("fixed", numbers);*/
/*
std::cout << "Press Enter to Exit ;-)\n";
std::cin.get();
*/
return 0;
}