-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parallel_static_gcc and basic test coverage
This is a somewhat more elaborate example which uses multiple threads, lambdas and std::async which has the tendency to stress our dwarf debug symbol resolution code. More on that in a follow-up patch. For now, this test only uncovered an issue in PerfParserTestClient::convertToText, where we iterated over a QHash to generate text output, which is not going to produce stable results. Instead, we now convert to a stable QMap first and output that. Furthermore, the test harness is updated to also allow us to test never version than 0.5 that we got in the past, i.e. 0.6 is now expected for the new data files I'm adding here. Change-Id: I2de65503b2c853528b301166a5b58a406d34a059 Reviewed-by: Ulf Hermann <[email protected]>
- Loading branch information
Showing
7 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file added
BIN
+14.5 KB
tests/auto/perfdata/parallel_static_gcc/perf.data.zstd.expected.txt.zlib
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
#include <cmath> | ||
#include <complex> | ||
#include <future> | ||
#include <iostream> | ||
#include <mutex> | ||
#include <random> | ||
#include <thread> | ||
#include <vector> | ||
|
||
using namespace std; | ||
|
||
double worker() | ||
{ | ||
uniform_real_distribution<double> uniform(-1E5, 1E5); | ||
default_random_engine engine; | ||
double s = 0; | ||
for (int i = 0; i < 10000; ++i) { | ||
s += norm(complex<double>(uniform(engine), uniform(engine))); | ||
} | ||
cout << s << endl; | ||
return s; | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
const int numTasks = argc > 1 ? stoi(argv[1]) : std::thread::hardware_concurrency(); | ||
vector<std::future<double>> results; | ||
for (int i = 0; i < numTasks; ++i) { | ||
results.push_back(async(launch::async, [i]() { | ||
return worker() * i; | ||
})); | ||
} | ||
return 0; | ||
} | ||
|