-
Notifications
You must be signed in to change notification settings - Fork 36
[wip] [feature] timeit xmagic enabled for native and lite case #289
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #289 +/- ##
==========================================
+ Coverage 80.87% 83.18% +2.30%
==========================================
Files 20 22 +2
Lines 957 1130 +173
Branches 88 98 +10
==========================================
+ Hits 774 940 +166
- Misses 183 190 +7
... and 2 files with indirect coverage changes
🚀 New features to boost your workflow:
|
Thanks a lot for this @kr-2003 Hopefully you were able to get past the output re-direction thingy we were discussing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 68. Check the log or trigger a new build to see more.
@@ -26,47 +27,66 @@ | |||
|
|||
using Args = std::vector<const char*>; | |||
|
|||
void* createInterpreter(const Args &ExtraArgs = {}) { | |||
Args ClangArgs = {/*"-xc++"*/"-v"}; // ? {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"}; | |||
void* createInterpreter(const Args& ExtraArgs = {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function 'createInterpreter' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
void* createInterpreter(const Args& ExtraArgs = {}) | |
static void* createInterpreter(const Args& ExtraArgs = {}) |
ClangArgs.push_back("-isystem"); | ||
ClangArgs.push_back(CxxInclude.c_str()); | ||
} | ||
if (std::find_if( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::find_if" is directly included [misc-include-cleaner]
src/xinterpreter.cpp:21:
- #ifndef EMSCRIPTEN
+ #include <algorithm>
+ #ifndef EMSCRIPTEN
if (std::find_if( | ||
ExtraArgs.begin(), | ||
ExtraArgs.end(), | ||
[](const std::string& s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::string" is directly included [misc-include-cleaner]
src/xinterpreter.cpp:21:
- #ifndef EMSCRIPTEN
+ #include <string>
+ #ifndef EMSCRIPTEN
) | ||
== ExtraArgs.end()) | ||
{ | ||
std::string resource_dir = Cpp::DetectResourceDir(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "Cpp::DetectResourceDir" is directly included [misc-include-cleaner]
src/xinterpreter.cpp:21:
- #ifndef EMSCRIPTEN
+ #include <clang/Interpreter/CppInterOp.h>
+ #ifndef EMSCRIPTEN
std::string resource_dir = Cpp::DetectResourceDir(); | ||
if (resource_dir.empty()) | ||
{ | ||
std::cerr << "Failed to detect the resource-dir\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::cerr" is directly included [misc-include-cleaner]
src/xinterpreter.cpp:21:
- #ifndef EMSCRIPTEN
+ #include <iostream>
+ #ifndef EMSCRIPTEN
ClangArgs.push_back(resource_dir.c_str()); | ||
} | ||
std::vector<std::string> CxxSystemIncludes; | ||
Cpp::DetectSystemCompilerIncludePaths(CxxSystemIncludes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "Cpp::DetectSystemCompilerIncludePaths" is directly included [misc-include-cleaner]
Cpp::DetectSystemCompilerIncludePaths(CxxSystemIncludes);
^
ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end()); | ||
// FIXME: We should process the kernel input options and conditionally pass | ||
// the gpu args here. | ||
return Cpp::CreateInterpreter(ClangArgs /*, {"-cuda"}*/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "Cpp::CreateInterpreter" is directly included [misc-include-cleaner]
return Cpp::CreateInterpreter(ClangArgs /*, {"-cuda"}*/);
^
err = Cpp::EndStdStreamCapture(); | ||
std::cout << out; | ||
} | ||
struct StreamRedirectRAII |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: class 'StreamRedirectRAII' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
struct StreamRedirectRAII
^
} | ||
struct StreamRedirectRAII | ||
{ | ||
std::string& err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: member 'err' of type 'std::string &' (aka 'basic_string &') is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]
std::string& err;
^
StreamRedirectRAII(std::string& e) | ||
: err(e) | ||
{ | ||
Cpp::BeginStdStreamCapture(Cpp::kStdErr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "Cpp::BeginStdStreamCapture" is directly included [misc-include-cleaner]
Cpp::BeginStdStreamCapture(Cpp::kStdErr);
^
Yes, there are some things left to do here. Although the feature is working fine for now.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 60. Check the log or trigger a new build to see more.
StreamRedirectRAII(std::string& e) | ||
: err(e) | ||
{ | ||
Cpp::BeginStdStreamCapture(Cpp::kStdErr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "Cpp::kStdErr" is directly included [misc-include-cleaner]
Cpp::BeginStdStreamCapture(Cpp::kStdErr);
^
: err(e) | ||
{ | ||
Cpp::BeginStdStreamCapture(Cpp::kStdErr); | ||
Cpp::BeginStdStreamCapture(Cpp::kStdOut); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "Cpp::kStdOut" is directly included [misc-include-cleaner]
Cpp::BeginStdStreamCapture(Cpp::kStdOut);
^
|
||
~StreamRedirectRAII() | ||
{ | ||
std::string out = Cpp::EndStdStreamCapture(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "Cpp::EndStdStreamCapture" is directly included [misc-include-cleaner]
std::string out = Cpp::EndStdStreamCapture();
^
{ | ||
std::string out = Cpp::EndStdStreamCapture(); | ||
err = Cpp::EndStdStreamCapture(); | ||
std::cout << out; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::cout" is directly included [misc-include-cleaner]
std::cout << out;
^
interpreter::interpreter(int argc, const char* const* argv) : | ||
xmagics() | ||
interpreter::interpreter(int argc, const char* const* argv) | ||
: xmagics() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: initializer for member 'xmagics' is redundant [readability-redundant-member-init]
: xmagics() | |
: |
auto found1 = found++; | ||
while (isspace(code[++found1])) ; | ||
return xeus::create_is_complete_reply("incomplete", code.substr(found, found1-found)); | ||
while (isspace(code[++found1])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "isspace" is directly included [misc-include-cleaner]
src/xinterpreter.cpp:21:
- #ifndef EMSCRIPTEN
+ #include <cctype>
+ #ifndef EMSCRIPTEN
|
||
#include "execution.hpp" | ||
#include "xeus-cpp/xinterpreter.hpp" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: included header xinterpreter.hpp is not used directly [misc-include-cleaner]
|
||
namespace xcpp | ||
{ | ||
struct StreamRedirectRAII |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: class 'StreamRedirectRAII' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
struct StreamRedirectRAII
^
{ | ||
struct StreamRedirectRAII | ||
{ | ||
std::string& err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: member 'err' of type 'std::string &' (aka 'basic_string &') is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]
std::string& err;
^
{ | ||
struct StreamRedirectRAII | ||
{ | ||
std::string& err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::string" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <string>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 48. Check the log or trigger a new build to see more.
{ | ||
std::string out = Cpp::EndStdStreamCapture(); | ||
err = Cpp::EndStdStreamCapture(); | ||
std::cout << out; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::cout" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <iostream>
{ | ||
} | ||
|
||
void timeit::get_options(argparser& argpars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'get_options' can be made static [readability-convert-member-functions-to-static]
src/xmagics/execution.hpp:47:
- void get_options(argparser& argpars);
+ static void get_options(argparser& argpars);
{ | ||
} | ||
|
||
void timeit::get_options(argparser& argpars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "xcpp::argparser" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:12:
- #include "clang/Interpreter/CppInterOp.h"
+ #include "xeus-cpp/xoptions.hpp"
+ #include "clang/Interpreter/CppInterOp.h"
.nargs(0); | ||
} | ||
|
||
std::string timeit::inner(std::size_t number, const std::string& code, int exec_counter) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'inner' can be made static [readability-convert-member-functions-to-static]
src/xmagics/execution.hpp:48:
- std::string inner(std::size_t number, const std::string& code, int exec_counter) const;
+ static std::string inner(std::size_t number, const std::string& code, int exec_counter) ;
std::string timeit::inner(std::size_t number, const std::string& code, int exec_counter) const | |
std::string timeit::inner(std::size_t number, const std::string& code, int exec_counter) |
.nargs(0); | ||
} | ||
|
||
std::string timeit::inner(std::size_t number, const std::string& code, int exec_counter) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::size_t" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <cstddef>
std::string timeit::inner(std::size_t number, const std::string& code, int exec_counter) const | ||
{ | ||
static std::size_t counter = 0; // Ensure unique lambda names | ||
std::string unique_id = std::to_string(counter++); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::to_string" is directly included [misc-include-cleaner]
std::string unique_id = std::to_string(counter++);
^
{ | ||
static std::size_t counter = 0; // Ensure unique lambda names | ||
std::string unique_id = std::to_string(counter++); | ||
std::string timeit_code = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: redundant string initialization [readability-redundant-string-init]
std::string timeit_code = ""; | |
std::string timeit_code; |
timeit_code += "auto user_code_" + unique_id + " = []() {\n"; | ||
timeit_code += " " + code + "\n"; | ||
timeit_code += "};\n"; | ||
timeit_code += "get_elapsed_time_" + std::to_string(exec_counter) + "(" + std::to_string(number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::to_string" is directly included [misc-include-cleaner]
timeit_code += "get_elapsed_time_" + std::to_string(exec_counter) + "(" + std::to_string(number)
^
return timeit_code; | ||
} | ||
|
||
std::string timeit::_format_time(double timespan, std::size_t precision) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method '_format_time' can be made static [readability-convert-member-functions-to-static]
src/xmagics/execution.hpp:49:
- std::string _format_time(double timespan, std::size_t precision) const;
+ static std::string _format_time(double timespan, std::size_t precision) ;
std::string timeit::_format_time(double timespan, std::size_t precision) const | |
std::string timeit::_format_time(double timespan, std::size_t precision) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 39. Check the log or trigger a new build to see more.
|
||
std::string timeit::_format_time(double timespan, std::size_t precision) const | ||
{ | ||
std::vector<std::string> units{"s", "ms", "us", "ns"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::vector" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <vector>
{ | ||
std::vector<std::string> units{"s", "ms", "us", "ns"}; | ||
std::vector<double> scaling{1, 1e3, 1e6, 1e9}; | ||
std::ostringstream output; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::ostringstream" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <sstream>
std::vector<std::string> units{"s", "ms", "us", "ns"}; | ||
std::vector<double> scaling{1, 1e3, 1e6, 1e9}; | ||
std::ostringstream output; | ||
int order; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'order' is not initialized [cppcoreguidelines-init-variables]
int order; | |
int order = 0; |
|
||
if (timespan > 0.0) | ||
{ | ||
order = std::min(-static_cast<int>(std::floor(std::floor(std::log10(timespan)) / 3)), 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::floor" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <cmath>
|
||
if (timespan > 0.0) | ||
{ | ||
order = std::min(-static_cast<int>(std::floor(std::floor(std::log10(timespan)) / 3)), 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::log10" is directly included [misc-include-cleaner]
order = std::min(-static_cast<int>(std::floor(std::floor(std::log10(timespan)) / 3)), 3);
^
|
||
if (timespan > 0.0) | ||
{ | ||
order = std::min(-static_cast<int>(std::floor(std::floor(std::log10(timespan)) / 3)), 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::min" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <algorithm>
{ | ||
order = 3; | ||
} | ||
output.precision(precision); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'std::size_t' (aka 'unsigned long') to signed type 'streamsize' (aka 'long') is implementation-defined [cppcoreguidelines-narrowing-conversions]
output.precision(precision);
^
void timeit::execute(std::string& line, std::string& cell) | ||
{ | ||
exec_counter++; | ||
argparser argpars("timeit", XEUS_CPP_VERSION, argparse::default_arguments::none); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "XEUS_CPP_VERSION" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:9:
- #include "xeus-cpp/xinterpreter.hpp"
+ #include "xeus-cpp/xeus_cpp_config.hpp"
+ #include "xeus-cpp/xinterpreter.hpp"
void timeit::execute(std::string& line, std::string& cell) | ||
{ | ||
exec_counter++; | ||
argparser argpars("timeit", XEUS_CPP_VERSION, argparse::default_arguments::none); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "argparse::default_arguments" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <argparse/argparse.hpp>
code += " " + s; | ||
} | ||
} | ||
catch (std::logic_error& e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::logic_error" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <stdexcept>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 30. Check the log or trigger a new build to see more.
void timeit::operator()(const std::string& line) | ||
{ | ||
std::string cline = line; | ||
std::string ccell = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: redundant string initialization [readability-redundant-string-init]
std::string ccell = ""; | |
std::string ccell; |
execute(cline, ccell); | ||
} | ||
|
||
void timeit::get_options(argparser& argpars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'get_options' can be made static [readability-convert-member-functions-to-static]
src/xmagics/execution.hpp:35:
- void get_options(argparser& argpars);
+ static void get_options(argparser& argpars);
.nargs(0); | ||
} | ||
|
||
std::string timeit::inner(std::size_t number, const std::string& code, int exec_counter) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'inner' can be made static [readability-convert-member-functions-to-static]
src/xmagics/execution.hpp:36:
- std::string inner(std::size_t number, const std::string& code, int exec_counter) const;
+ static std::string inner(std::size_t number, const std::string& code, int exec_counter) ;
std::string timeit::inner(std::size_t number, const std::string& code, int exec_counter) const | |
std::string timeit::inner(std::size_t number, const std::string& code, int exec_counter) |
return timeit_code; | ||
} | ||
|
||
std::string timeit::_format_time(double timespan, std::size_t precision) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method '_format_time' can be made static [readability-convert-member-functions-to-static]
src/xmagics/execution.hpp:37:
- std::string _format_time(double timespan, std::size_t precision) const;
+ static std::string _format_time(double timespan, std::size_t precision) ;
std::string timeit::_format_time(double timespan, std::size_t precision) const | |
std::string timeit::_format_time(double timespan, std::size_t precision) |
{ | ||
if (trim(cell).empty() && (argpars["-h"] == false)) | ||
{ | ||
std::cerr << "No expression given to evaluate" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
std::cerr << "No expression given to evaluate" << std::endl; | |
std::cerr << "No expression given to evaluate" << '\n'; |
{ | ||
if (trim(cell).empty() && (argpars["-h"] == false)) | ||
{ | ||
std::cerr << "No expression given to evaluate" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::cerr" is directly included [misc-include-cleaner]
std::cerr << "No expression given to evaluate" << std::endl;
^
{ | ||
if (trim(cell).empty() && (argpars["-h"] == false)) | ||
{ | ||
std::cerr << "No expression given to evaluate" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::endl" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <ostream>
src/xmagics/execution.cpp
Outdated
bool hadError = false; | ||
|
||
bool compilation_result = true; | ||
compilation_result = Cpp::Process("#include <chrono>\n#include <iostream>\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: Value stored to 'compilation_result' is never read [clang-analyzer-deadcode.DeadStores]
compilation_result = Cpp::Process("#include <chrono>\n#include <iostream>\n");
^
Additional context
src/xmagics/execution.cpp:156: Value stored to 'compilation_result' is never read
compilation_result = Cpp::Process("#include <chrono>\n#include <iostream>\n");
^
} | ||
)"; | ||
|
||
compilation_result = Cpp::Process(timing_function.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: Value stored to 'compilation_result' is never read [clang-analyzer-deadcode.DeadStores]
compilation_result = Cpp::Process(timing_function.c_str());
^
Additional context
src/xmagics/execution.cpp:172: Value stored to 'compilation_result' is never read
compilation_result = Cpp::Process(timing_function.c_str());
^
try | ||
{ | ||
StreamRedirectRAII R(err); | ||
std::ostringstream buffer_out, buffer_err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
std::ostringstream buffer_out, buffer_err; | |
std::ostringstream buffer_out; | |
std::ostringstream buffer_err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 21. Check the log or trigger a new build to see more.
bool hadError = false; | ||
|
||
bool compilation_result = true; | ||
compilation_result = Cpp::Process("#include <chrono>\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: Value stored to 'compilation_result' is never read [clang-analyzer-deadcode.DeadStores]
compilation_result = Cpp::Process("#include <chrono>\n");
^
Additional context
src/xmagics/execution.cpp:156: Value stored to 'compilation_result' is never read
compilation_result = Cpp::Process("#include <chrono>\n");
^
{ | ||
StreamRedirectRAII R(err); | ||
std::ostringstream buffer_out, buffer_err; | ||
std::streambuf* old_cout = std::cout.rdbuf(buffer_out.rdbuf()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::streambuf" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <streambuf>
std::cout.rdbuf(old_cout); | ||
std::cerr.rdbuf(old_cerr); | ||
} | ||
catch (std::exception& e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::exception" is directly included [misc-include-cleaner]
src/xmagics/execution.cpp:13:
+ #include <exception>
{ | ||
for (std::size_t n = 0; n < 10; ++n) | ||
{ | ||
number = std::pow(10, n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'typename __gnu_cxx::__promote_2<int, unsigned long>::__type' (aka 'double') to 'int' [cppcoreguidelines-narrowing-conversions]
number = std::pow(10, n);
^
{ | ||
for (std::size_t n = 0; n < 10; ++n) | ||
{ | ||
number = std::pow(10, n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::pow" is directly included [misc-include-cleaner]
number = std::pow(10, n);
^
{ | ||
number = std::pow(10, n); | ||
std::string timeit_code = inner(number, code, exec_counter); | ||
std::ostringstream buffer_out, buffer_err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
std::ostringstream buffer_out, buffer_err; | |
std::ostringstream buffer_out; | |
std::ostringstream buffer_err; |
auto res_ptr = Cpp::Evaluate(timeit_code.c_str(), &hadError); | ||
std::cout.rdbuf(old_cout); | ||
std::cerr.rdbuf(old_cerr); | ||
output = std::to_string(res_ptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::to_string" is directly included [misc-include-cleaner]
output = std::to_string(res_ptr);
^
std::cerr.rdbuf(old_cerr); | ||
output = std::to_string(res_ptr); | ||
err += buffer_err.str(); | ||
double elapsed_time = std::stod(output) * 1e-6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::stod" is directly included [misc-include-cleaner]
double elapsed_time = std::stod(output) * 1e-6;
^
for (std::size_t r = 0; r < static_cast<std::size_t>(repeat); ++r) | ||
{ | ||
std::string timeit_code = inner(number, code, exec_counter); | ||
std::ostringstream buffer_out, buffer_err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
std::ostringstream buffer_out, buffer_err; | |
std::ostringstream buffer_out; | |
std::ostringstream buffer_err; |
{ | ||
stdev += (all_runs[r] - mean) * (all_runs[r] - mean); | ||
} | ||
stdev = std::sqrt(stdev / repeat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::sqrt" is directly included [misc-include-cleaner]
stdev = std::sqrt(stdev / repeat);
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 11. Check the log or trigger a new build to see more.
|
||
std::cout << _format_time(mean, precision) << " +- " << _format_time(stdev, precision); | ||
std::cout << " per loop (mean +- std. dev. of " << repeat << " run" << ((repeat == 1) ? ", " : "s "); | ||
std::cout << number << " loop" << ((number == 1) ? "" : "s") << " each)" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
std::cout << number << " loop" << ((number == 1) ? "" : "s") << " each)" << std::endl; | |
std::cout << number << " loop" << ((number == 1) ? "" : "s") << " each)" << '\n'; |
std::cout << " per loop (mean +- std. dev. of " << repeat << " run" << ((repeat == 1) ? ", " : "s "); | ||
std::cout << number << " loop" << ((number == 1) ? "" : "s") << " each)" << std::endl; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: namespace 'xcpp' not terminated with a closing comment [llvm-namespace-comment]
src/xmagics/execution.cpp:-1:
+ // namespace xcpp
Additional context
src/xmagics/execution.cpp:14: namespace 'xcpp' starts here
namespace xcpp
^
************************************************************************************/ | ||
|
||
#ifndef XMAGICS_EXECUTION_HPP | ||
#define XMAGICS_EXECUTION_HPP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: header guard does not follow preferred style [llvm-header-guard]
#define XMAGICS_EXECUTION_HPP | |
#ifndef GITHUB_WORKSPACE_SRC_XMAGICS_EXECUTION_HPP | |
#define GITHUB_WORKSPACE_SRC_XMAGICS_EXECUTION_HPP |
{ | ||
public: | ||
|
||
XEUS_CPP_API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "XEUS_CPP_API" is directly included [misc-include-cleaner]
src/xmagics/execution.hpp:14:
- #include "xeus-cpp/xmagics.hpp"
+ #include "xeus-cpp/xeus_cpp_config.hpp"
+ #include "xeus-cpp/xmagics.hpp"
public: | ||
|
||
XEUS_CPP_API | ||
virtual void operator()(const std::string& line) override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 'virtual' is redundant since the function is already declared 'override' [cppcoreguidelines-explicit-virtual-functions]
virtual void operator()(const std::string& line) override; | |
void operator()(const std::string& line) override; |
virtual void operator()(const std::string& line) override; | ||
|
||
XEUS_CPP_API | ||
virtual void operator()(const std::string& line, const std::string& cell) override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 'virtual' is redundant since the function is already declared 'override' [cppcoreguidelines-explicit-virtual-functions]
virtual void operator()(const std::string& line, const std::string& cell) override; | |
void operator()(const std::string& line, const std::string& cell) override; |
XEUS_CPP_API | ||
virtual void operator()(const std::string& line, const std::string& cell) override; | ||
|
||
public: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: redundant access specifier has the same accessibility as the previous access specifier [readability-redundant-access-specifiers]
public: | |
Additional context
src/xmagics/execution.hpp:21: previously declared here
public:
^
private: | ||
|
||
void get_options(argparser& argpars); | ||
std::string inner(std::size_t number, const std::string& code, int exec_counter) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function 'inner' should be marked [[nodiscard]] [modernize-use-nodiscard]
std::string inner(std::size_t number, const std::string& code, int exec_counter) const; | |
[[nodiscard]] std::string inner(std::size_t number, const std::string& code, int exec_counter) const; |
|
||
void get_options(argparser& argpars); | ||
std::string inner(std::size_t number, const std::string& code, int exec_counter) const; | ||
std::string _format_time(double timespan, std::size_t precision) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function '_format_time' should be marked [[nodiscard]] [modernize-use-nodiscard]
std::string _format_time(double timespan, std::size_t precision) const; | |
[[nodiscard]] std::string _format_time(double timespan, std::size_t precision) const; |
|
||
void get_options(argparser& argpars); | ||
std::string inner(std::size_t number, const std::string& code, int exec_counter) const; | ||
std::string _format_time(double timespan, std::size_t precision) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: invalid case style for function '_format_time' [readability-identifier-naming]
std::string _format_time(double timespan, std::size_t precision) const; | |
std::string format_time(double timespan, std::size_t precision) const; |
Native
timeit-native.mp4
Lite
timeit-lite.mp4