• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Open-Sn / opensn / 20388244010

20 Dec 2025 12:27AM UTC coverage: 74.437% (+0.02%) from 74.415%
20388244010

push

github

web-flow
Merge pull request #882 from andrsd/issue/90-local-cell-idxs

Unifying integer types for local cell face/side indices

13 of 15 new or added lines in 2 files covered. (86.67%)

43 existing lines in 8 files now uncovered.

18677 of 25091 relevant lines covered (74.44%)

66914505.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.18
/framework/utils/timer.cc
1
// SPDX-FileCopyrightText: 2024 The OpenSn Authors <https://open-sn.github.io/opensn/>
2
// SPDX-License-Identifier: MIT
3

4
#include "framework/utils/timer.h"
5
#include <cmath>
6
#include <ctime>
7
#include <iomanip>
8
#include <sstream>
9
#include <thread>
10

11
namespace opensn
12
{
13

14
Timer::Timer() noexcept
2,824✔
15
{
16
  start_time_ = std::chrono::steady_clock::now();
2,824✔
17
}
2,824✔
18

19
void
20
Timer::Reset()
390✔
21
{
22
  start_time_ = std::chrono::steady_clock::now();
390✔
23
}
390✔
24

25
double
26
Timer::GetTime() const
54,294✔
27
{
28
  using namespace std::chrono;
54,294✔
29

30
  steady_clock::time_point newTime = std::chrono::steady_clock::now();
54,294✔
31
  auto time_span = duration_cast<duration<double>>(newTime - start_time_);
54,294✔
32

33
  return time_span.count() * 1000.0;
54,294✔
34
}
35

36
std::string
37
Timer::GetTimeString() const
54,294✔
38
{
39
  double time_sec = this->GetTime() / 1000.0;
54,294✔
40
  int hours = std::floor(time_sec / 3600);
54,294✔
41
  int minutes = std::floor((time_sec - 3600 * hours) / 60);
54,294✔
42
  // Keep seconds as a double since we want fractional seconds
43
  double seconds = time_sec - 3600.0 * hours - 60.0 * minutes;
54,294✔
44

45
  std::ostringstream oss;
54,294✔
46
  oss << std::setw(2) << std::setfill('0') << hours << ':' << std::setw(2) << std::setfill('0')
54,294✔
47
      << minutes << ':' << std::setw(4) << std::setfill('0') << std::fixed << std::setprecision(1)
54,294✔
48
      << seconds;
54,294✔
49

50
  return oss.str();
108,588✔
51
}
54,294✔
52

53
std::string
54
Timer::GetLocalDateTimeString()
314✔
55
{
56
  using namespace std::chrono;
314✔
57
  std::time_t now = system_clock::to_time_t(system_clock::now());
314✔
58

59
  char s[30];
314✔
60
  size_t end = std::strftime(s, 30, "%Y-%m-%d %H:%M:%S", std::localtime(&now)); // NOLINT
314✔
61
  s[29] = '\0';
314✔
62
  if (end < 30)
314✔
63
    s[end] = '\0';
314✔
64
  return s;
314✔
65
}
66

67
void
UNCOV
68
Sleep(std::chrono::duration<double> time)
×
69
{
UNCOV
70
  std::this_thread::sleep_for(time);
×
UNCOV
71
}
×
72

73
} // namespace opensn
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc