Commit 4eb8996f authored by Leon Pyka's avatar Leon Pyka
Browse files

added timer

parent 60d343ec
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
#include <cstdint>
#include <ctime>
#include <fstream>
#include <iostream>
#include <sstream>
#include <mpi.h>
@@ -49,9 +51,21 @@ void export_sel(const char* filename, vector<uint32_t> &sel, vector<double> &ths
        f.close();
}

void writeElapsedTime(clock_t start_time, clock_t end_time) {
    double elapsed_time = (end_time - start_time) / CLOCKS_PER_SEC;
    ofstream outfile("elapsed_time.txt");
    if (outfile.is_open()) {
        outfile << "delta t: " << elapsed_time << "\n";
        outfile.close();
    }
    cout << "\nelapsed time " << elapsed_time;
}


int main(int argc, char **argv)
{
    clock_t start_time = clock();

    MPI_Init(NULL,NULL);
    // Get the number of processes
    int comm_size = 1;
@@ -113,6 +127,8 @@ int main(int argc, char **argv)
        bs_stream << "brokenlist_sorted_seed" << seed << "_" << r;
        rfm.export_sbl(bs_stream.str().c_str());
    }
    
    clock_t end_time = clock();
    writeElapsedTime(start_time, end_time);
    MPI_Finalize();
    
}