mirror of
https://github.com/Z3Prover/z3
synced 2025-05-08 00:05:46 +00:00
Reorganizing source code. Created util dir
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
630ba0c675
commit
2c464d413d
153 changed files with 0 additions and 0 deletions
58
src/util/timeit.cpp
Normal file
58
src/util/timeit.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*++
|
||||
Copyright (c) 2006 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
timeit.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Support for timers.
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2006-09-22
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"timeit.h"
|
||||
#include"memory_manager.h"
|
||||
#include"stopwatch.h"
|
||||
#include<iomanip>
|
||||
|
||||
struct timeit::imp {
|
||||
stopwatch m_watch;
|
||||
char const * m_msg;
|
||||
std::ostream & m_out;
|
||||
double m_start_memory;
|
||||
|
||||
imp(char const * msg, std::ostream & out):
|
||||
m_msg(msg),
|
||||
m_out(out),
|
||||
m_start_memory(static_cast<double>(memory::get_allocation_size())/static_cast<double>(1024*1024)) {
|
||||
m_watch.start();
|
||||
}
|
||||
|
||||
~imp() {
|
||||
m_watch.stop();
|
||||
double end_memory = static_cast<double>(memory::get_allocation_size())/static_cast<double>(1024*1024);
|
||||
m_out << m_msg << ", time: " << std::fixed << std::setprecision(2) << m_watch.get_seconds()
|
||||
<< " secs, memory: (before " << std::fixed << std::setprecision(2) << m_start_memory
|
||||
<< ", after " << std::fixed << std::setprecision(2) << end_memory << ")"
|
||||
<< std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
timeit::timeit(bool enable, char const * msg, std::ostream & out) {
|
||||
if (enable)
|
||||
m_imp = alloc(imp, msg, out);
|
||||
else
|
||||
m_imp = 0;
|
||||
}
|
||||
|
||||
timeit::~timeit() {
|
||||
if (m_imp)
|
||||
dealloc(m_imp);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue