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

Open-Sn / opensn / 18300593117

06 Oct 2025 10:47PM UTC coverage: 74.862% (-0.2%) from 75.031%
18300593117

push

github

web-flow
Merge pull request #759 from wdhawkins/performance

Sweep performance optimizations

294 of 302 new or added lines in 15 files covered. (97.35%)

334 existing lines in 80 files now uncovered.

17788 of 23761 relevant lines covered (74.86%)

61852783.95 hits per line

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

87.1
/framework/logging/log_stream.h
1
// SPDX-FileCopyrightText: 2024 The OpenSn Authors <https://open-sn.github.io/opensn/>
2
// SPDX-License-Identifier: MIT
3

4
#pragma once
5

6
#include <iostream>
7
#include <sstream>
8
#include "stringstream_color.h"
9

10
namespace opensn
11
{
12

13
/// Log stream for adding header information to a string stream.
14
class LogStream : public std::stringstream
15
{
16
private:
17
  std::ostream* log_stream_;
18
  std::string log_header_;
19
  const bool dummy_;
20
  bool use_color_;
21

22
public:
23
  LogStream(std::ostream* output_stream,
747,461✔
24
            std::string header,
25
            bool dummy_flag = false,
26
            bool use_color = false)
27
    : log_stream_(output_stream),
1,494,922✔
28
      log_header_(std::move(header)),
747,461✔
29
      dummy_(dummy_flag),
747,461✔
30
      use_color_(use_color)
747,461✔
31
  {
32
  }
747,461✔
33

34
  LogStream(const LogStream&) = delete;
35
  LogStream& operator=(const LogStream&) = delete;
36

37
  ~LogStream() noexcept override
747,461✔
38
  {
39
    if (dummy_)
40
      return;
41

42
    try
43
    {
44
      std::string content = this->str();
45
      if (content.empty())
46
        return;
47

48
      std::istringstream iss(content);
49
      std::string line;
50
      std::string oline;
51
      std::string reset_str = use_color_ ? StringStreamColor(StringStreamColorCode::RESET) : "";
52
      while (std::getline(iss, line))
53
      {
54
        oline += log_header_;
55
        oline += line;
56
        oline += reset_str;
57
        oline += "\n";
58
      }
59

60
      if (!oline.empty())
61
        *log_stream_ << oline << std::flush;
62
    }
63
    catch (...) // NOLINT(bugprone-empty-catch)
64
    {
65
      // No exceptions escape the destructor...
66
    }
67
  }
2,215,539✔
68
};
747,461✔
69

747,461✔
70
struct DummyStream : public std::ostream
734,039✔
71
{
13,422✔
72
  struct DummyStreamBuffer : std::streambuf
13,422✔
73
  {
×
74
    int overflow(int c) override { return c; };
13,422✔
75
  } buffer;
13,422✔
76

13,422✔
77
  DummyStream() : std::ostream(&buffer) {}
25,987✔
78
  ~DummyStream() override = default;
33,337✔
79
};
19,915✔
80

19,915✔
81
} // namespace opensn
19,915✔
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