Skip to content

Commit

Permalink
Replace util/timer* with std::chrono
Browse files Browse the repository at this point in the history
The old timer API was written in 2004 and is superseded by std::chrono.
All clients of the old API are updated to use std::chrono, and the old
API classes are removed. This is in preparation for a commit that uses
features of chrono that are not present in the old time API.
  • Loading branch information
karkhaz committed Feb 14, 2018
1 parent 0f20482 commit 3f6965b
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 333 deletions.
17 changes: 9 additions & 8 deletions src/cbmc/all_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Author: Daniel Kroening, [email protected]

#include "all_properties_class.h"

#include <util/time_stopping.h>
#include <chrono>

#include <util/xml.h>
#include <util/json.h>

Expand Down Expand Up @@ -56,8 +57,8 @@ safety_checkert::resultt bmc_all_propertiest::operator()()

solver.set_message_handler(get_message_handler());

// stop the time
absolute_timet sat_start=current_time();
auto now = std::chrono::steady_clock::now();
auto sat_start = std::chrono::time_point_cast<std::chrono::seconds>(now);

bmc.do_conversion();

Expand Down Expand Up @@ -131,12 +132,12 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
g.second.status=goalt::statust::SUCCESS;
}

// output runtime

{
absolute_timet sat_stop=current_time();
status() << "Runtime decision procedure: "
<< (sat_stop-sat_start) << "s" << eom;
now = std::chrono::steady_clock::now();
auto sat_stop = std::chrono::time_point_cast<std::chrono::seconds>(now);

status() << "Runtime decision procedure: " << (sat_stop - sat_start).count()
<< "s" << eom;
}

// report
Expand Down
14 changes: 7 additions & 7 deletions src/cbmc/bmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Author: Daniel Kroening, [email protected]

#include "bmc.h"

#include <chrono>
#include <fstream>
#include <iostream>
#include <memory>

#include <util/string2int.h>
#include <util/source_location.h>
#include <util/string_utils.h>
#include <util/time_stopping.h>
#include <util/message.h>
#include <util/json.h>
#include <util/cprover_prefix.h>
Expand Down Expand Up @@ -154,20 +154,20 @@ bmct::run_decision_procedure(prop_convt &prop_conv)

prop_conv.set_message_handler(get_message_handler());

// stop the time
absolute_timet sat_start=current_time();
auto now = std::chrono::steady_clock::now();
auto sat_start = std::chrono::time_point_cast<std::chrono::seconds>(now);

do_conversion();

status() << "Running " << prop_conv.decision_procedure_text() << eom;

decision_proceduret::resultt dec_result=prop_conv.dec_solve();
// output runtime

{
absolute_timet sat_stop=current_time();
status() << "Runtime decision procedure: "
<< (sat_stop-sat_start) << "s" << eom;
now = std::chrono::steady_clock::now();
auto sat_stop = std::chrono::time_point_cast<std::chrono::seconds>(now);
status() << "Runtime decision procedure: " << (sat_stop - sat_start).count()
<< "s" << eom;
}

return dec_result;
Expand Down
16 changes: 8 additions & 8 deletions src/cbmc/bmc_cover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Author: Daniel Kroening, [email protected]

#include "bmc.h"

#include <util/time_stopping.h>
#include <chrono>

#include <util/xml.h>
#include <util/xml_expr.h>
#include <util/json.h>
Expand Down Expand Up @@ -191,8 +192,8 @@ bool bmc_covert::operator()()

solver.set_message_handler(get_message_handler());

// stop the time
absolute_timet sat_start=current_time();
auto now = std::chrono::steady_clock::now();
auto sat_start = std::chrono::time_point_cast<std::chrono::seconds>(now);

// Collect _all_ goals in `goal_map'.
// This maps property IDs to 'goalt'
Expand Down Expand Up @@ -251,12 +252,11 @@ bool bmc_covert::operator()()

cover_goals();

// output runtime

{
absolute_timet sat_stop=current_time();
status() << "Runtime decision procedure: "
<< (sat_stop-sat_start) << "s" << eom;
now = std::chrono::steady_clock::now();
auto sat_stop = std::chrono::time_point_cast<std::chrono::seconds>(now);
status() << "Runtime decision procedure: " << (sat_stop - sat_start).count()
<< "s" << eom;
}

// report
Expand Down
14 changes: 8 additions & 6 deletions src/cbmc/fault_localization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ Author: Peter Schrammel

#include "fault_localization.h"

#include <chrono>

#include <util/threeval.h>
#include <util/arith_tools.h>
#include <util/symbol.h>
#include <util/std_expr.h>
#include <util/message.h>
#include <util/time_stopping.h>
#include <util/xml_expr.h>

#include <solvers/prop/minimize.h>
Expand Down Expand Up @@ -245,8 +246,8 @@ fault_localizationt::run_decision_procedure(prop_convt &prop_conv)

prop_conv.set_message_handler(bmc.get_message_handler());

// stop the time
absolute_timet sat_start=current_time();
auto now = std::chrono::steady_clock::now();
auto sat_start = std::chrono::time_point_cast<std::chrono::seconds>(now);

bmc.do_conversion();

Expand All @@ -259,9 +260,10 @@ fault_localizationt::run_decision_procedure(prop_convt &prop_conv)
// output runtime

{
absolute_timet sat_stop=current_time();
status() << "Runtime decision procedure: "
<< (sat_stop-sat_start) << "s" << eom;
now = std::chrono::steady_clock::now();
auto sat_stop = std::chrono::time_point_cast<std::chrono::seconds>(now);
status() << "Runtime decision procedure: " << (sat_stop - sat_start).count()
<< "s" << eom;
}

return dec_result;
Expand Down
8 changes: 6 additions & 2 deletions src/cbmc/symex_coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Date: March 2016

#include "symex_coverage.h"

#include <chrono>
#include <iostream>
#include <fstream>
#include <sstream>

#include <util/time_stopping.h>
#include <util/xml.h>
#include <util/string2int.h>
#include <util/cprover_prefix.h>
Expand Down Expand Up @@ -387,6 +387,10 @@ void symex_coveraget::build_cobertura(
std::string overall_branch_rate_str=
rate(overall_cov.branches_covered, overall_cov.branches_total);

auto now = std::chrono::system_clock::now();
auto current_time = std::chrono::time_point_cast<std::chrono::seconds>(now);
std::time_t tt = std::chrono::system_clock::to_time_t(current_time);

// <coverage line-rate="0.0" branch-rate="0.0" lines-covered="1"
// lines-valid="1" branches-covered="1"
// branches-valid="1" complexity="0.0"
Expand All @@ -404,7 +408,7 @@ void symex_coveraget::build_cobertura(
xml_coverage.set_attribute("complexity", "0.0");
xml_coverage.set_attribute("version", "2.1.1");
xml_coverage.set_attribute("timestamp",
std::to_string(current_time().get_t()));
std::to_string(tt));

xmlt &packages=xml_coverage.new_element("packages");

Expand Down
2 changes: 0 additions & 2 deletions src/util/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ SRC = arith_tools.cpp \
tempdir.cpp \
tempfile.cpp \
threeval.cpp \
time_stopping.cpp \
timer.cpp \
type.cpp \
type_eq.cpp \
typecheck.cpp \
Expand Down
69 changes: 0 additions & 69 deletions src/util/time_stopping.cpp

This file was deleted.

110 changes: 0 additions & 110 deletions src/util/time_stopping.h

This file was deleted.

Loading

0 comments on commit 3f6965b

Please sign in to comment.