Skip to content
Snippets Groups Projects
Commit 37979643 authored by toole1's avatar toole1
Browse files

monad update, yay\!

git-svn-id: https://subversion.cs.illinois.edu/svn/cs225@5039 6fbd10e7-183d-0410-a318-cb416676e4f2
parent 7c4de36b
No related branches found
No related tags found
No related merge requests found
monad identification file monad identification file
This file is used for monad directory identification This file is used for monad directory identification
Built by toole1 on linux4.ews.illinois.edu Built by toole1 on linux3.ews.illinois.edu
Build Date: Tue Oct 11 03:11:28 CDT 2011 Build Date: Sat Oct 15 03:57:48 CDT 2011
#ifndef PIPESTREAM_H #ifndef UTIL_PIPESTREAM_H
#define PIPESTREAM_H #define UTIL_PIPESTREAM_H
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
......
...@@ -32,7 +32,7 @@ using namespace monad_shared; ...@@ -32,7 +32,7 @@ using namespace monad_shared;
namespace opts namespace opts
{ {
bool verbose = false; bool verbose = true;
bool redirect_test_output = true; bool redirect_test_output = true;
} }
...@@ -63,10 +63,11 @@ namespace proxy ...@@ -63,10 +63,11 @@ namespace proxy
double runtime_ratio[TIME_COUNT] = double runtime_ratio[TIME_COUNT] =
{ {
1.0, 1.0,
2.0,
2.30103, // for 200/100
// 2.82842712,
4.0, 4.0,
5.20411998, // for 400/100
// 8.0,
16.0,
64,
std::numeric_limits<double>::max() std::numeric_limits<double>::max()
}; };
const char * runtime_str[TIME_COUNT] = const char * runtime_str[TIME_COUNT] =
...@@ -76,6 +77,7 @@ namespace proxy ...@@ -76,6 +77,7 @@ namespace proxy
"O(nlogn)", "O(nlogn)",
// "O(nrootn)", // "O(nrootn)",
"O(n^2)", "O(n^2)",
"O(n^3)",
"O(infinity)" "O(infinity)"
}; };
} }
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#ifndef MONAD_PROXY_H #ifndef MONAD_PROXY_H
#define MONAD_PROXY_H #define MONAD_PROXY_H
#include <cmath>
#include <iostream> #include <iostream>
#include <limits> #include <limits>
#include <map> #include <map>
...@@ -223,6 +225,7 @@ enum proxy_runtime_t ...@@ -223,6 +225,7 @@ enum proxy_runtime_t
NLOGN_TIME, NLOGN_TIME,
// NROOTN_TIME, // NROOTN_TIME,
N2_TIME, N2_TIME,
N3_TIME,
INFINITE_TIME, INFINITE_TIME,
TIME_COUNT TIME_COUNT
}; };
...@@ -231,20 +234,25 @@ namespace proxy ...@@ -231,20 +234,25 @@ namespace proxy
{ {
extern double runtime_ratio[TIME_COUNT]; extern double runtime_ratio[TIME_COUNT];
extern const char * runtime_str[TIME_COUNT]; extern const char * runtime_str[TIME_COUNT];
template <typename Generator, typename Timer>
uint64_t timeIterationsImpl(Generator gen, Timer timeFunctor, size_t input_size);
template <typename Generator, typename Timer> template <typename Generator, typename Timer>
uint64_t timeIterations(Generator gen, Timer timeFunctor, size_t input_size); uint64_t timeIterations(Generator gen, Timer timeFunctor, size_t input_size);
template <typename GenResult, typename GenArg, typename Timer>
uint64_t timeIterations(GenResult (*gen)(GenArg), Timer timeFunctor, size_t input_size);
} }
#define ASSERT_TIME(gen, functor, expectedTime) \ #define ASSERT_TIME(gen, functor, expectedTime) \
do { \ do { \
uint64_t diff200 = proxy::timeIterations(gen, functor, 200); \ uint64_t diff400 = proxy::timeIterations(gen, functor, 400); \
uint64_t diff100 = proxy::timeIterations(gen, functor, 100); \ uint64_t diff100 = proxy::timeIterations(gen, functor, 100); \
std::cout << diff200 << std::endl; \ std::cout << diff400 << std::endl; \
std::cout << diff100 << std::endl; \ std::cout << diff100 << std::endl; \
double ratio = (double)(diff200)/(diff100); \ double ratio = (double)(diff400)/(diff100); \
double diffFromExpected = abs(ratio - proxy::runtime_ratio[expectedTime]); \ double diffFromExpected = abs(ratio - proxy::runtime_ratio[expectedTime]); \
double diffFromWrong = abs(ratio - proxy::runtime_ratio[expectedTime + 1]); \ double diffFromWrong = abs(ratio - proxy::runtime_ratio[expectedTime + 1]); \
std::cout << ratio << std::endl; \ std::cout << ratio << std::endl; \
if (diffFromWrong < diffFromExpected) \ if (diffFromWrong < diffFromExpected) \
FAIL(string("Runtime was larger than ") + proxy::runtime_str[expectedTime] + util::to_string(ratio)); \ FAIL(string("Runtime was larger than ") + proxy::runtime_str[expectedTime] + util::to_string(ratio)); \
} while(0) } while(0)
...@@ -254,7 +262,22 @@ namespace proxy { ...@@ -254,7 +262,22 @@ namespace proxy {
template <typename Generator, typename Timer> template <typename Generator, typename Timer>
uint64_t timeIterations(Generator gen, Timer timeFunctor, size_t input_size) uint64_t timeIterations(Generator gen, Timer timeFunctor, size_t input_size)
{ {
const size_t num_iterations = 10000; return timeIterationsImpl(
bind1st(mem_fun(&Generator::operator()), &gen),
timeFunctor,
input_size);
}
template <typename GenResult, typename GenArg, typename Timer>
uint64_t timeIterations(GenResult (*gen)(GenArg), Timer timeFunctor, size_t input_size)
{
return timeIterationsImpl(ptr_fun(gen), timeFunctor, input_size);
}
template <typename Generator, typename Timer>
uint64_t timeIterationsImpl(Generator gen, Timer timeFunctor, size_t input_size)
{
const size_t num_iterations = 2000;
std::vector<typename Generator::result_type> inputs; std::vector<typename Generator::result_type> inputs;
inputs.reserve(num_iterations); inputs.reserve(num_iterations);
for (size_t i = 0; i < num_iterations; i++) for (size_t i = 0; i < num_iterations; i++)
...@@ -267,6 +290,7 @@ uint64_t timeIterations(Generator gen, Timer timeFunctor, size_t input_size) ...@@ -267,6 +290,7 @@ uint64_t timeIterations(Generator gen, Timer timeFunctor, size_t input_size)
return endtime - starttime; return endtime - starttime;
} }
inline int32_t bitflags(unsigned long a, unsigned long b, unsigned long c, inline int32_t bitflags(unsigned long a, unsigned long b, unsigned long c,
unsigned long d, unsigned long e) unsigned long d, unsigned long e)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment