Skip to content

Commit

Permalink
Merge pull request #89 from vittorioromeo/consistent_formatting
Browse files Browse the repository at this point in the history
Fix inconsistent formatting of '****' for "expensive headers"
  • Loading branch information
aras-p committed Apr 24, 2023
2 parents 477c9e3 + a09c2d2 commit ee073b3
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 29 deletions.
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -67,7 +67,7 @@ Compilation (1761 times):
4011 ms: sqlite3VdbeExec (External/sqlite/sqlite3.c)
2737 ms: ProgressiveRuntimeManager::Update() (artifacts/Editor_Src_GI_Progressive_0.cpp)
*** Expensive headers:
**** Expensive headers:
136567 ms: /BuildEnvironment/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h (included 92 times, avg 1484 ms), included via:
CocoaObjectImages.o AppKit.h (2033 ms)
OSXNativeWebViewWindowHelper.o OSXNativeWebViewWindowHelper.h AppKit.h (2007 ms)
Expand Down
2 changes: 1 addition & 1 deletion src/Analysis.cpp
Expand Up @@ -486,7 +486,7 @@ void Analysis::EndAnalysis()

if (!expensiveHeaders.empty())
{
fprintf(out, "%s%s*** Expensive headers%s:\n", col::kBold, col::kMagenta, col::kReset);
fprintf(out, "%s%s**** Expensive headers%s:\n", col::kBold, col::kMagenta, col::kReset);
for (const auto& e : expensiveHeaders)
{
const auto& es = headerMap[e.first];
Expand Down
51 changes: 37 additions & 14 deletions src/main.cpp
Expand Up @@ -15,6 +15,7 @@
#include <time.h>
#include <algorithm>
#include <set>
#include <cassert>

#ifdef _MSC_VER
struct IUnknown; // workaround for old Win SDK header failures when using /permissive-
Expand Down Expand Up @@ -44,22 +45,44 @@ static void ReadFileToString(const std::string& path, std::string& str)

static bool CompareIgnoreNewlines(const std::string& a, const std::string& b)
{
size_t alen = a.size();
size_t blen = b.size();
size_t ia = 0, ib = 0;
for (; ia < alen && ib < blen; ++ia, ++ib)
// Find the next non-newline character in `str`, starting from `idx`.
//
// `idx` will be modified. If such a character is found, `true` is returned,
// and `idx` will be the index of the found non-newline character.
//
// Otherwise, `false` is returned.
const auto findNextNonNewLineChar = [](const std::string& str, std::size_t& idx)
{
if (a[ia] == '\r')
++ia;
if (b[ib] == '\r')
++ib;
if (ia < alen && ib < blen)
if (a[ia] != b[ib])
return false;
}
if (ia != alen || ib != blen)
for (; idx < str.size(); ++idx)
if (str[idx] != '\n' && str[idx] != '\r')
return true;

return false;
return true;
};

std::size_t idxA = 0;
std::size_t idxB = 0;

while (true)
{
const bool foundA = findNextNonNewLineChar(a, idxA);
const bool foundB = findNextNonNewLineChar(b, idxB);

if (!foundA && !foundB) // Reached the end of both files.
return true;

if (foundA != foundB) // Mismatch: reached end of only one file.
return false;

if (a[idxA] != b[idxB]) // Mismatch: characters do not match.
return false;

++idxA;
++idxB;
}

assert(false);
return false;
}

static void PrintUsage()
Expand Down
1 change: 0 additions & 1 deletion tests/clang11-pid-45/_AnalysisOutputExpected.txt
Expand Up @@ -7,4 +7,3 @@ Compilation (1 times):
1 ms: main (test.cc)

**** Function sets that took longest to compile / optimize:

Expand Up @@ -143,7 +143,7 @@ Compilation (4 times):
8 ms: print_float(std::__1::basic_stringstream<$>&, float) (2 times, avg 4 ms)
8 ms: GlslFunction::GlslFunction(std::__1::basic_string<$> const&, std::__... (2 times, avg 4 ms)

*** Expensive headers:
**** Expensive headers:
794 ms: hlslang/OSDependent/Mac/osinclude.h (included 1 times, avg 794 ms), included via:
hlslLinker.json (794 ms)

Expand All @@ -166,4 +166,3 @@ Compilation (4 times):

3 ms: hlslang/GLSLCodeGen/hlslCrossCompiler.h (included 1 times, avg 3 ms), included via:
hlslLinker.json (3 ms)

Expand Up @@ -129,7 +129,7 @@ Compilation (2 times):
0 ms: std::unique_ptr<$>::get_deleter() (1 times, avg 0 ms)
0 ms: sal::detail::operator<<(sal::detail::StreamStart const&, char const*) (1 times, avg 0 ms)

*** Expensive headers:
**** Expensive headers:
1287 ms: /libo2/include/vcl/svapp.hxx (included 1 times, avg 1287 ms), included via:
SkiaHelper.json (1287 ms)

Expand Down Expand Up @@ -159,4 +159,3 @@ Compilation (2 times):

1 ms: /libo2/include/sal/log.hxx (included 1 times, avg 1 ms), included via:
SkiaHelper.json (1 ms)

3 changes: 1 addition & 2 deletions tests/self-win-clang-13.0/_AnalysisOutputExpected.txt
Expand Up @@ -146,7 +146,7 @@ Compilation (8 times):
10 ms: void __cdecl std::_Pop_heap_hole_by_index<$>(struct std::pair<$> *, ... (1 times, avg 10 ms)
10 ms: public: __cdecl ska::detailv8::sherwood_v8_table<$>::~sherwood_v8_ta... (7 times, avg 1 ms)

*** Expensive headers:
**** Expensive headers:
775 ms: src/BuildEvents.h (included 3 times, avg 258 ms), included via:
Analysis.json Analysis.h (263 ms)
BuildEvents.json (257 ms)
Expand Down Expand Up @@ -190,4 +190,3 @@ Compilation (8 times):
vector (12 ms)
BuildEvents.h string xstring (12 ms)
Analysis.h BuildEvents.h string xstring (12 ms)

3 changes: 1 addition & 2 deletions tests/self-win-clang-cl-10.0rc2/_AnalysisOutputExpected.txt
Expand Up @@ -143,7 +143,7 @@ Compilation (6 times):
12 ms: void __cdecl std::_Sort_unchecked<$>(struct sajson::internal::object... (1 times, avg 12 ms)
12 ms: void __cdecl FindParentChildrenIndices(struct IndexedVector<$> &) (2 times, avg 6 ms)

*** Expensive headers:
**** Expensive headers:
701 ms: C:/Program Files (x86)/Windows Kits/10/include/10.0.18362.0/um/windows.h (included 2 times, avg 350 ms), included via:
Allocator.json (352 ms)
main.json sokol_time.h (348 ms)
Expand Down Expand Up @@ -185,4 +185,3 @@ Compilation (6 times):
BuildEvents.h string xstring iosfwd xstddef cstdlib (12 ms)
algorithm xmemory cstdlib (12 ms)
Analysis.h BuildEvents.h string xstring iosfwd xstddef cstdlib (12 ms)

3 changes: 1 addition & 2 deletions tests/self-win-clang-cl-9.0rc2/_AnalysisOutputExpected.txt
Expand Up @@ -131,7 +131,7 @@ Compilation (3 times):
0 ms: public: class std::basic_string<$> & __cdecl std::basic_string<$>::a... (1 times, avg 0 ms)
0 ms: public: void __cdecl std::allocator<$>::deallocate(wchar_t *const, u... (1 times, avg 0 ms)

*** Expensive headers:
**** Expensive headers:
1740 ms: C:/Program Files (x86)/Windows Kits/10/include/10.0.17763.0/um/windows.h (included 3 times, avg 580 ms), included via:
Colors.json (715 ms)
Utils.json (683 ms)
Expand Down Expand Up @@ -173,4 +173,3 @@ Compilation (3 times):
3 ms: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.22.27905/include/xatomic.h (included 2 times, avg 1 ms), included via:
algorithm xmemory (1 ms)
Utils.h string xstring xmemory (1 ms)

3 changes: 1 addition & 2 deletions tests/verylong-symbol-name-38/_AnalysisOutputExpected.txt
Expand Up @@ -81,7 +81,7 @@ Compilation (2 times):
**** Function sets that took longest to compile / optimize:
0 ms: void __cdecl std::_Deallocate<$>(void *, unsigned __int64) (1 times, avg 0 ms)

*** Expensive headers:
**** Expensive headers:
29 ms: C:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/ucrt/stdio.h (included 1 times, avg 29 ms), included via:
string xstring iosfwd cstdio (29 ms)

Expand Down Expand Up @@ -111,4 +111,3 @@ Compilation (2 times):

1 ms: C:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/ucrt/ctype.h (included 1 times, avg 1 ms), included via:
string cctype (1 ms)

0 comments on commit ee073b3

Please sign in to comment.