Lint: use automated tooling to reformat C++ and CMakeLists files (#2103)

* Add initial clang tidy / clang format config files

* Clang format the entire codebase

```
find ./src -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./include -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./Web -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./dev -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
find ./wrappers -regextype posix-extended -regex '.*\.(cpp|hpp|c|h|cxx|hxx)$' | xargs clang-format-12 -style=file -i -fallback-style=none
```

* Add a .cmake-format file and reformat CmakeLists.txt with it

https://github.com/cheshirekow/cmake_format

* Add a clang-format workflow


only runs on PRs, only on touched files
This commit is contained in:
Julien Marrec
2022-03-31 16:51:48 +02:00
committed by GitHub
parent 3b8ed97fbc
commit 05c8cf503b
164 changed files with 40642 additions and 37967 deletions

View File

@@ -8,35 +8,33 @@
// A hack to make powerpc happy since sysClkRateGet not found
#if defined(__powerpc__)
#define CLOCKS_PER_SEC 1000
# define CLOCKS_PER_SEC 1000
#endif
namespace CoolProp{
namespace CoolProp {
void compare_REFPROP_and_CoolProp(const std::string &fluid, CoolProp::input_pairs inputs, double val1, double val2, std::size_t N, double d1, double d2)
{
time_t t1,t2;
void compare_REFPROP_and_CoolProp(const std::string& fluid, CoolProp::input_pairs inputs, double val1, double val2, std::size_t N, double d1,
double d2) {
time_t t1, t2;
shared_ptr<AbstractState> State(AbstractState::factory("HEOS", fluid));
t1 = clock();
for (std::size_t ii = 0; ii < N; ++ii)
{
State->update(inputs, val1 + ii*d1, val2 + ii*d2);
for (std::size_t ii = 0; ii < N; ++ii) {
State->update(inputs, val1 + ii * d1, val2 + ii * d2);
}
t2 = clock();
double elap = ((double)(t2-t1))/CLOCKS_PER_SEC/((double)N)*1e6;
std::cout << format("Elapsed time for CoolProp is %g us/call\n",elap);
double elap = ((double)(t2 - t1)) / CLOCKS_PER_SEC / ((double)N) * 1e6;
std::cout << format("Elapsed time for CoolProp is %g us/call\n", elap);
State.reset(AbstractState::factory("REFPROP", fluid));
t1 = clock();
for (std::size_t ii = 0; ii < N; ++ii)
{
State->update(inputs, val1 + ii*d1, val2 + ii*d2);
for (std::size_t ii = 0; ii < N; ++ii) {
State->update(inputs, val1 + ii * d1, val2 + ii * d2);
}
t2 = clock();
elap = ((double)(t2-t1))/CLOCKS_PER_SEC/((double)N)*1e6;
std::cout << format("Elapsed time for REFPROP is %g us/call\n",elap);
elap = ((double)(t2 - t1)) / CLOCKS_PER_SEC / ((double)N) * 1e6;
std::cout << format("Elapsed time for REFPROP is %g us/call\n", elap);
}
} /* namespace CoolProp */