Hybrid Query Processing Engine for Coprocessing in Database Systems
HyPE
unittest_cpp_interface.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 #include <stdlib.h>
00005 
00006 #include <hype.hpp>
00007 
00008 using namespace hype;
00009 using namespace std;
00010 
00011 int main(){
00012 
00013    Scheduler& scheduler=Scheduler::instance();
00014 
00015 // scheduler.addAlgorithm("SORT","BubbleSort","LEAST_SQUARES","PERIODIC");
00016 // scheduler.addAlgorithm("SORT","MergeSort","LEAST_SQUARES","EVENTBASED");
00017 // scheduler.addAlgorithm("SORT","QuickSort","SPLINES","HYBRID");
00018 
00019    scheduler.addAlgorithm("SORT","Bubblesort",CPU,"Least Squares 1D","Periodic Recomputation");
00020    scheduler.addAlgorithm("SORT","Mergesort",CPU,"Least Squares 1D","Periodic Recomputation");
00021    scheduler.addAlgorithm("SORT","Quicksort",CPU,"Least Squares 1D","Periodic Recomputation");
00022 
00023    if(!scheduler.setOptimizationCriterion("SORT","Response Time")) std::cout << "Error: Could not set Response Time as Optimization Criterion!" << std::endl;        else cout << "Success..." << endl;
00024    //if(!scheduler.setOptimizationCriterion("MERGE","Throughput")) std::cout << "Error" << std::endl;
00025 
00026    if(!scheduler.setStatisticalMethod("Quicksort","Least Squares 1D")) std::cout << "Error" << std::endl; else cout << "Success..." << endl;
00027    if(!scheduler.setStatisticalMethod("Bubblesort","Least Squares 1D")) std::cout << "Error" << std::endl; else cout << "Success..." << endl;
00028 
00029    if(!scheduler.setRecomputationHeuristic("Quicksort","Periodic Recomputation")) std::cout << "Error" << std::endl; else cout << "Success..." << endl;
00030    if(!scheduler.setRecomputationHeuristic("Bubblesort","Periodic Recomputation")) std::cout << "Error" << std::endl; else cout << "Success..." << endl;
00031 
00032    Tuple t;
00033    t.push_back(2.5);
00034 
00035    //string algorithm_name = scheduler.getOptimalAlgorithmName("SORT",t);
00036 
00037 
00038 
00039    vector<double> feature_values_of_input_data;
00040    feature_values_of_input_data.push_back(5.5);
00041    feature_values_of_input_data.push_back(2.3);
00042 
00043    for(int i=0;i<1000;i++){
00044    uint64_t begin = core::getTimestamp();
00045    SchedulingDecision sched_dec = scheduler.getOptimalAlgorithmName("SORT",t);
00046    cout << "Line: " << i << " ";
00047    if(sched_dec.getNameofChoosenAlgorithm()=="Bubblesort"){
00048       //sleep(1);
00049       AlgorithmMeasurement alg_measure(sched_dec);
00050       cout << "Hallo" << endl; 
00051       alg_measure.afterAlgorithmExecution(); 
00052    }else if(sched_dec.getNameofChoosenAlgorithm()=="Quicksort"){
00053       AlgorithmMeasurement alg_measure(sched_dec);
00054       cout << "Hallo Hallöchen lieber Leser" << endl; 
00055       alg_measure.afterAlgorithmExecution(); 
00056    }else if(sched_dec.getNameofChoosenAlgorithm()=="Mergesort"){
00057       AlgorithmMeasurement alg_measure(sched_dec);
00058       cout << "Hi" << endl; 
00059       alg_measure.afterAlgorithmExecution(); 
00060    }
00061    
00062    uint64_t end = core::getTimestamp();
00063 
00064    uint64_t result = end-begin;
00065    if(begin>end) {
00066       cout << "Fatal Error" << endl;
00067       abort();
00068    }
00069    cout << result << endl;
00070    }
00071 
00072    
00073    //string algorithm_name = sched_dec.getNameofChoosenAlgorithm();
00074 
00075  return 0;
00076 };
00077 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines