尝试同步
This commit is contained in:
13
test.cpp
13
test.cpp
@@ -27,6 +27,7 @@ vector<vector<double>> matrixMultiply(const vector<vector<double>>& A, const vec
|
||||
for (size_t j = 0; j < m; j++) {
|
||||
for (size_t k = 0; k < p; k++) {
|
||||
result[i][j] += A[i][k] * B[k][j];
|
||||
TracyPlot("matrixMultiply", result[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +47,7 @@ vector<vector<double>> generateRandomMatrix(size_t rows, size_t cols) {
|
||||
for (size_t i = 0; i < rows; i++) {
|
||||
for (size_t j = 0; j < cols; j++) {
|
||||
matrix[i][j] = dis(gen);
|
||||
TracyPlot("generateRandomMatrix", matrix[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +70,9 @@ void quickSort(vector<int>& arr, int low, int high) {
|
||||
}
|
||||
swap(arr[i + 1], arr[high]);
|
||||
int pi = i + 1;
|
||||
|
||||
|
||||
TracyPlot("quickSort.low", (int64_t)low);
|
||||
TracyPlot("quickSort.high", (int64_t)high);
|
||||
quickSort(arr, low, pi - 1);
|
||||
quickSort(arr, pi + 1, high);
|
||||
}
|
||||
@@ -88,6 +92,7 @@ vector<int> sieveOfEratosthenes(int n) {
|
||||
primes.push_back(i);
|
||||
for (int j = i * 2; j <= n; j += i) {
|
||||
isPrime[j] = false;
|
||||
TracyPlot("sieveOfEratosthenes", (isPrime[j] ? 1.0 : 0.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,7 +113,8 @@ double calculatePi(int iterations) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
double x = dis(gen);
|
||||
double y = dis(gen);
|
||||
|
||||
|
||||
TracyPlot("calculatePi", (x * x + y * y));
|
||||
if (x * x + y * y <= 1.0) {
|
||||
insideCircle++;
|
||||
}
|
||||
@@ -120,6 +126,7 @@ double calculatePi(int iterations) {
|
||||
// 斐波那契数列(递归)
|
||||
long long fibonacci(int n) {
|
||||
ZoneScoped;
|
||||
TracyPlot("fibonacci", (int64_t)n);
|
||||
|
||||
if (n <= 1) return n;
|
||||
return fibonacci(n - 1) + fibonacci(n - 2);
|
||||
@@ -149,6 +156,7 @@ double dotProduct(const vector<double>& a, const vector<double>& b) {
|
||||
double result = 0.0;
|
||||
for (size_t i = 0; i < a.size(); i++) {
|
||||
result += a[i] * b[i];
|
||||
TracyPlot("dotProduct", result);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -161,6 +169,7 @@ void complexMathOperations(int iterations) {
|
||||
double sum = 0.0;
|
||||
for (int i = 1; i <= iterations; i++) {
|
||||
sum += sin(i) * cos(i) + tan(i / 100.0) + sqrt(i) + log(i);
|
||||
TracyPlot("complexMathOperations", sum);
|
||||
}
|
||||
|
||||
cout << "复杂数学计算结果: " << sum << endl;
|
||||
|
||||
Reference in New Issue
Block a user