tests/benchmark_tools.h
author Alpar Juttner <alpar@cs.elte.hu>
Sun, 11 Dec 2011 16:08:52 +0100
changeset 12 4eab99ff2666
parent 11 cf6519daa7fa
child 13 0ab493e5250e
permissions -rw-r--r--
Add Copyright headers
alpar@12
     1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
alpar@12
     2
 *
alpar@12
     3
 * This file is a part of LEMON, a generic C++ optimization library.
alpar@12
     4
 *
alpar@12
     5
 * Copyright (C) 2003-2011
alpar@12
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@12
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@12
     8
 *
alpar@12
     9
 * Permission to use, modify and distribute this software is granted
alpar@12
    10
 * provided that this copyright notice appears in all copies. For
alpar@12
    11
 * precise terms see the accompanying LICENSE file.
alpar@12
    12
 *
alpar@12
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@12
    14
 * express or implied, and with no claim as to its suitability for any
alpar@12
    15
 * purpose.
alpar@12
    16
 *
alpar@12
    17
 */
alpar@12
    18
alpar@10
    19
#ifndef BENCHMARK_TOOLS_H
alpar@10
    20
#define BENCHMARK_TOOLS_H
alpar@10
    21
alpar@10
    22
#include<string>
alpar@10
    23
#include<iostream>
alpar@10
    24
#include<iomanip>
alpar@10
    25
#include<lemon/time_measure.h>
alpar@10
    26
alpar@11
    27
extern std::string test_name;
alpar@11
    28
extern std::string instance_name;
alpar@10
    29
alpar@11
    30
extern const std::string DATADIR_PATH;
alpar@11
    31
alpar@11
    32
alpar@11
    33
inline void logTime(const std::string &_instance_name,
alpar@11
    34
		    const std::string &subtest_name,
alpar@11
    35
		    const lemon::TimeStamp &time)
alpar@10
    36
{
alpar@11
    37
  std::cout << "*** " << test_name
alpar@11
    38
	    << ' ' << _instance_name
alpar@11
    39
	    << ' ' << subtest_name
alpar@11
    40
	    << ' ' << std::setiosflags(std::ios::fixed) << std::setprecision(4)
alpar@10
    41
	    << time.realTime() << ' '
alpar@10
    42
            << time.realTime()/(time.userTime()+time.systemTime()) - 1.0
alpar@10
    43
            << std::endl;
alpar@10
    44
}
alpar@10
    45
alpar@11
    46
inline void logTime(const std::string &subtest_name,
alpar@11
    47
		    const lemon::TimeStamp &time)
alpar@11
    48
{
alpar@11
    49
  logTime(instance_name,subtest_name,time);
alpar@11
    50
}
alpar@11
    51
alpar@10
    52
#endif