/** @file time.cpp
 *
 *  @author Cory Alexander Balaton (coryab)
 *  @author Janita Ovidie Sandtrøen Willumsen (janitaws)
 *
 *  @version 0.1
 *
 *  @brief Timing various things
 *
 *  @bug No known bugs
 * */
#include "data_type.hpp"
#include "monte_carlo.hpp"
#include "utils.hpp"

#include <omp.h>
#include <ostream>

void time_lattice_sizes()
{
    std::string outfile = "output/timing/lattice_sizes.txt";
    std::ofstream ofile;

    int lattice_sizes[] = {20, 40, 60, 80, 100};

    utils::mkpath(utils::dirname(outfile));
    ofile.open(outfile);
    double t0, t1;
    for (int L : lattice_sizes) {
        t0 = omp_get_wtime();
        montecarlo::phase_transition(L, 2.1, 2.4, 40, 100000,
                                     montecarlo::mcmc_parallel,
                                     "output/garbage/null.txt");
        t1 = omp_get_wtime();
        ofile << utils::scientific_format(L) << ','
              << utils::scientific_format(t1 - t0) << '\n';
    }
    ofile.close();
}

void time_sample_sizes()
{
    std::string outfile = "output/timing/sample_sizes.txt";
    std::ofstream ofile;

    int sample_sizes[] = {1000, 10000, 100000};

    utils::mkpath(utils::dirname(outfile));
    ofile.open(outfile);
    double t0, t1;
    for (int samples : sample_sizes) {
        t0 = omp_get_wtime();
        montecarlo::phase_transition(20, 2.1, 2.4, 40, samples,
                                     montecarlo::mcmc_parallel,
                                     "output/garbage/null.txt");
        t1 = omp_get_wtime();
        ofile << utils::scientific_format(samples) << ','
              << utils::scientific_format(t1 - t0) << '\n';
    }
    ofile.close();
}

int main()
{
    time_lattice_sizes();
    time_sample_sizes();
    return 0;
}
