feat(frontends/lean): suppress profiling information for declarations that take less than 0.01 secs to be processed
This commit is contained in:
parent
0acdcd487b
commit
cbc3c0cf4f
2 changed files with 16 additions and 8 deletions
|
@ -30,6 +30,11 @@ Author: Leonardo de Moura
|
||||||
#include "frontends/lean/update_environment_exception.h"
|
#include "frontends/lean/update_environment_exception.h"
|
||||||
#include "frontends/lean/nested_declaration.h"
|
#include "frontends/lean/nested_declaration.h"
|
||||||
|
|
||||||
|
// We don't display profiling information for declarations that take less than 0.01 secs
|
||||||
|
#ifndef LEAN_PROFILE_THRESHOLD
|
||||||
|
#define LEAN_PROFILE_THRESHOLD 0.01
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
static environment declare_universe(parser & p, environment env, name const & n, bool local) {
|
static environment declare_universe(parser & p, environment env, name const & n, bool local) {
|
||||||
if (local) {
|
if (local) {
|
||||||
|
@ -799,7 +804,7 @@ class definition_cmd_fn {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
display_pos(msg);
|
display_pos(msg);
|
||||||
msg << " type checking time for " << m_name;
|
msg << " type checking time for " << m_name;
|
||||||
timeit timer(m_p.diagnostic_stream().get_stream(), msg.str().c_str());
|
timeit timer(m_p.diagnostic_stream().get_stream(), msg.str().c_str(), LEAN_PROFILE_THRESHOLD);
|
||||||
return ::lean::check(m_env, d);
|
return ::lean::check(m_env, d);
|
||||||
} else {
|
} else {
|
||||||
return ::lean::check(m_env, d);
|
return ::lean::check(m_env, d);
|
||||||
|
@ -955,7 +960,7 @@ class definition_cmd_fn {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
display_pos(msg);
|
display_pos(msg);
|
||||||
msg << " type elaboration time for " << m_name;
|
msg << " type elaboration time for " << m_name;
|
||||||
timeit timer(m_p.diagnostic_stream().get_stream(), msg.str().c_str());
|
timeit timer(m_p.diagnostic_stream().get_stream(), msg.str().c_str(), LEAN_PROFILE_THRESHOLD);
|
||||||
return m_p.elaborate_type(e, list<expr>(), clear_pre_info);
|
return m_p.elaborate_type(e, list<expr>(), clear_pre_info);
|
||||||
} else {
|
} else {
|
||||||
return m_p.elaborate_type(e, list<expr>(), clear_pre_info);
|
return m_p.elaborate_type(e, list<expr>(), clear_pre_info);
|
||||||
|
@ -968,7 +973,7 @@ class definition_cmd_fn {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
display_pos(msg);
|
display_pos(msg);
|
||||||
msg << " elaboration time for " << m_name;
|
msg << " elaboration time for " << m_name;
|
||||||
timeit timer(m_p.diagnostic_stream().get_stream(), msg.str().c_str());
|
timeit timer(m_p.diagnostic_stream().get_stream(), msg.str().c_str(), LEAN_PROFILE_THRESHOLD);
|
||||||
return m_p.elaborate_definition(def_name, type, value);
|
return m_p.elaborate_definition(def_name, type, value);
|
||||||
} else {
|
} else {
|
||||||
return m_p.elaborate_definition(def_name, type, value);
|
return m_p.elaborate_definition(def_name, type, value);
|
||||||
|
|
|
@ -11,20 +11,23 @@ Author: Leonardo de Moura
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
/**
|
/** \brief Low tech timer for used for testing. */
|
||||||
\brief Low tech timer for used for testing.
|
|
||||||
*/
|
|
||||||
class timeit {
|
class timeit {
|
||||||
std::ostream & m_out;
|
std::ostream & m_out;
|
||||||
std::string m_msg;
|
std::string m_msg;
|
||||||
|
double m_threshold; // we only display the result if time > m_threshold
|
||||||
clock_t m_start;
|
clock_t m_start;
|
||||||
public:
|
public:
|
||||||
timeit(std::ostream & out, char const * msg):m_out(out), m_msg(msg) {
|
timeit(std::ostream & out, char const * msg, double threshold):m_out(out), m_msg(msg), m_threshold(threshold) {
|
||||||
m_start = clock();
|
m_start = clock();
|
||||||
}
|
}
|
||||||
|
timeit(std::ostream & out, char const * msg):timeit(out, msg, -0.1) {}
|
||||||
~timeit() {
|
~timeit() {
|
||||||
clock_t end = clock();
|
clock_t end = clock();
|
||||||
m_out << m_msg << " " << std::fixed << std::setprecision(5) << ((static_cast<double>(end) - static_cast<double>(m_start)) / CLOCKS_PER_SEC) << " secs\n";
|
double result = ((static_cast<double>(end) - static_cast<double>(m_start)) / CLOCKS_PER_SEC);
|
||||||
|
if (result > m_threshold) {
|
||||||
|
m_out << m_msg << " " << std::fixed << std::setprecision(5) << result << " secs\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue