Commit 0ff34e23 authored by Constantin Pohl's avatar Constantin Pohl
Browse files

Minor remarks

parent f5926c35
......@@ -484,6 +484,9 @@ if (BUILD_PYTHON)
)
set_target_properties(pyfabric PROPERTIES PREFIX "" SUFFIX ".so")
if (BUILD_TEST_CASES)
add_subdirectory(testcases)
endif()
endif()
############################################################################################
......@@ -586,20 +589,8 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
############################################################################################
#
add_executable(barrierTrial testcases/barrierTrial.cpp)
target_link_libraries(barrierTrial pfabric_core)
add_executable(streamFromRestTrial testcases/streamFromRestTrial.cpp)
target_link_libraries(streamFromRestTrial pfabric_core)
add_executable(updateTableTrial testcases/updateTableTrial.cpp)
target_link_libraries(updateTableTrial pfabric_core)
add_executable(batchOpTrial testcases/batchOpTrial.cpp)
target_link_libraries(batchOpTrial pfabric_core)
add_executable(toTableTrial testcases/toTableTrial.cpp)
target_link_libraries(toTableTrial pfabric_core)
#add_executable(ExecutableName ExecutableFile.cpp)
#target_link_libraries(ExecutableName pfabric_core)
# show used compiler
message("Using Compiler: ${CMAKE_CXX_COMPILER_ID} (Config: ${CMAKE_BUILD_TYPE}).")
......@@ -166,8 +166,9 @@ PyPipe PyPipe::join(PyPipe other, bp::object pred) {
PyPipe PyPipe::partitionBy(bp::object fun, unsigned int numberPartitions ) {
auto pipe = boost::get<TuplePipe&>(pipeImpl);
return PyPipe(pipe.partitionBy([fun](auto tp) {
return bp::extract<std::size_t>(fun(get<0>(tp)));
return PyPipe(pipe.partitionBy([fun](auto tp) -> size_t {
auto res = fun(get<0>(tp));
return (size_t) bp::extract<size_t>(res);
}, numberPartitions));
}
......
add_executable(generator generator.cpp)
target_link_libraries(generator pfabric_core)
add_executable(barrierTrial barrierTrial.cpp)
target_link_libraries(barrierTrial pfabric_core)
add_executable(streamFromRestTrial streamFromRestTrial.cpp)
target_link_libraries(streamFromRestTrial pfabric_core)
add_executable(updateTableTrial updateTableTrial.cpp)
target_link_libraries(updateTableTrial pfabric_core)
add_executable(batchOpTrial batchOpTrial.cpp)
target_link_libraries(batchOpTrial pfabric_core)
add_executable(toTableTrial toTableTrial.cpp)
target_link_libraries(toTableTrial pfabric_core)
add_executable(measureTime measureTime.cpp)
target_link_libraries(measureTime pfabric_core)
......@@ -10,17 +10,21 @@ typedef TuplePtr<int,int,int> Tout;
int main(int argc, char **argv) {
auto start = chrono::steady_clock::now();
int main(int argc, char **argv) {
PFabricContext ctx;
auto t = ctx.createTopology();
StreamGenerator<Tout>::Generator gen ([](unsigned long n) -> Tout {
return makeTuplePtr((int)n, (int)n+10, (int)n+100) ;
});
auto s = t->newStreamFromFile("data.csv")
.extract<T1>(',')
.where([](auto tp, bool) { return get<1>(tp) % 2 != 0; } )
.map<Tout>([](auto tp, bool) { return makeTuplePtr(get<0>(tp), get<1>(tp), get<2>(tp)); } )
.print();
auto s = t->streamFromGenerator<T1>(gen, 5000000)
.where([](auto tp, bool) { return get<0>(tp) % 2 != 0; } )
.map<Tout>([](auto tp, bool) { return makeTuplePtr(get<0>(tp), get<1>(tp), get<2>(tp)); } )
;
auto start = chrono::steady_clock::now();
t->start();
t->wait();
......@@ -30,17 +34,5 @@ typedef TuplePtr<int,int,int> Tout;
std::cout << "Elapsed time in nanoseconds : "
<< chrono::duration_cast<chrono::nanoseconds>(end - start).count()
<< " ns" << std::endl;
std::cout << "Elapsed time in microseconds : "
<< chrono::duration_cast<chrono::microseconds>(end - start).count()
<< " µs" << std::endl;
std::cout << "Elapsed time in milliseconds : "
<< chrono::duration_cast<chrono::milliseconds>(end - start).count()
<< " ms" << std::endl;
std::cout << "Elapsed time in seconds : "
<< chrono::duration_cast<chrono::seconds>(end - start).count()
<< " sec" << std::endl;
}
......@@ -5,15 +5,15 @@ import pyfabric
import time
start = time.time_ns()
t = pyfabric.Topology()
p = t.stream_from_file("./csvFiles/pythonData.csv")\
.extract(',')\
.pfprint()
t.start()
p = t.streamFromGenerator(lambda n: (int(n), n+10, n+100), 5000000)\
.where(lambda x, o: x[0] % 2 !=0) \
.map(lambda t, o: (int(t[0]), t[1], t[2]))
start = time.time_ns()
t.start()
end = time.time_ns()
print(end - start, " ns")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment