Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: offer csv-formatted totals (by duration) output #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

juliangaal
Copy link

@juliangaal juliangaal commented Nov 4, 2024

This commit adds the ability to output csv-formatted Totals/TotalsByDuration information to an std::ostream.

I would find very useful for comparing multiple runs against each other, in the process of e.g. refactoring.

Let me know what you think, thanks.

BTW: I think this is unused

auto parentBranchPtr = mTreePtr->stack()[mTreePtr->stack().size() - 2];

@LMauricius
Copy link
Owner

LMauricius commented Nov 22, 2024

Hi, sorry for not getting around to reviewing sooner. Could you fix the indent formatting in the files? I'm not sure who's to blame, but I'd like to have both uniform formatting in the repo and not pollute commits with irrelevant changes. If I have to fix formatting, I'll do it later.

I added a few comments so after resolving them it's good to go.

@LMauricius
Copy link
Owner

You're right, that line is unused. I'll fix it later, thanks.

@juliangaal
Copy link
Author

juliangaal commented Nov 22, 2024

I used your provided clang-format file. which version of clang-format are you using?

clang-format --version
>>> Ubuntu clang-format version 14.0.0-1ubuntu1.1

I totally see you point about mixing code changes and formatting changes.

I'll prepare the feature-only commit in the next couple of days, if you don't mind. I don't see any of your comments in the 'Files Changed'-Tab though.

@LMauricius
Copy link
Owner

LMauricius commented Nov 27, 2024

That's weird. I have the same version.

Ubuntu clang-format version 14.0.0-1ubuntu1.1

Do you still not see the comments? I see them in the Files tab, and also here, above your last comment.

@juliangaal
Copy link
Author

Should pop up right here, I am confused. Scrolling all the way down along the git diff shows no comments, either

Screenshot from 2024-11-29 11-55-00

@LMauricius LMauricius self-requested a review December 10, 2024 21:31
void FuncProfilerTree::outputTotalsCSVToOStream(std::ostream &out) const
{
SStream ss;
out << "Function Name,Time (s),Call Number\n";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Header should probably be optional. Add a bool parameter?

@@ -152,6 +163,16 @@ String FuncProfilerTree::totalsByDurationStr(size_t indent, size_t indentSpaces)
return ss.str();
}

void FuncProfilerTree::outputTotalsByDurationCSVToOStream(std::ostream &out) const
{
out << "Time (s),Call Number,Function Name\n";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also make the header optional.

@@ -75,7 +76,16 @@ int main()
});
t1.join();

std::ofstream ofs("test.csv", std::ios::out | std::ios::trunc);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to output it to cout, like the other examples. This way the demo is showcase-only.

@@ -1,5 +1,6 @@
#include "MMeter.h"

#include <fstream>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better not to use fstream just for the demo, iostream is sufficient

@LMauricius
Copy link
Owner

Is this still the case?

@LMauricius
Copy link
Owner

Maybe there's a separate category for file comments?

@juliangaal
Copy link
Author

perfect, now I see. Let me work on the changes over the weekend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants