Skip to content
Snippets Groups Projects
Verified Commit 11950a4a authored by orestis.malaspin's avatar orestis.malaspin
Browse files

dates

parent dedc1309
No related branches found
No related tags found
No related merge requests found
Pipeline #38223 failed
......@@ -25,7 +25,8 @@ docker_clean: docker-compose.yml
puppeteer:
@echo "Setting chromium to $(CHROMIUM) for puppeteer"
@echo -e "{\n\"executablePath\":" \"$(CHROMIUM)\" ",\n\"args\": [\"--no-sandbox\"]\n}" > .puppeteer.json
# @echo -e "{\n\"executablePath\":" \"$(CHROMIUM)\" ",\n\"args\": [\"--no-sandbox\"]\n}" > .puppeteer.json
@echo "{\n\"executablePath\":" \"$(CHROMIUM)\" ",\n\"args\": [\"--no-sandbox\"]\n}" > .puppeteer.json
index.md: gen_index.sh
$(shell ./gen_index.sh)
......
---
title: "Arbres binaires"
date: "2024-03-07"
date: "2025-03-07"
---
# Les arbres binaires
......
......@@ -4,3 +4,17 @@ sum_one
sum_one_opt
sum_thousand
sum_thousand_opt
search
sum
sum_one
sum_one_opt
sum_thousand
sum_thousand_opt
sum_one
sum_one_opt
sum_thousand
sum_thousand_opt
sum_one
sum_one_opt
sum_thousand
sum_thousand_opt
......@@ -11,34 +11,35 @@
#endif
void init(int n, double tab[]) {
for (int i = 0; i < n; ++i) {
tab[i] = (double)rand() / (double)RAND_MAX;
}
for (int i = 0; i < n; ++i) {
tab[i] = (double)rand() / (double)RAND_MAX;
}
}
double sum(int n, double tab[]) {
double s = tab[0];
for (int i = 1; i < n; ++i) {
s += tab[i] * tab[i] * tab[i] * tab[i];
}
return s;
double s = tab[0];
for (int i = 1; i < n; ++i) {
s += tab[i] * tab[i] * tab[i] * tab[i];
}
return s;
}
int main() {
double tab[SIZE];
init(SIZE, tab);
double tab[SIZE];
init(SIZE, tab);
struct timespec tstart = {0, 0}, tend = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &tstart);
double s = 0;
for (int i = 0; i < NUM_TIMES; ++i) {
s += sum(SIZE, tab);
}
clock_gettime(CLOCK_MONOTONIC, &tend);
printf("the computation took about %.5f seconds\n",
(((double)tend.tv_sec + 1e-9 * tend.tv_nsec) -
((double)tstart.tv_sec + 1e-9 * tstart.tv_nsec)) /
NUM_TIMES);
struct timespec tstart = {0, 0}, tend = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &tstart);
double s = 0;
for (int i = 0; i < NUM_TIMES; ++i) {
s += sum(SIZE, tab);
}
clock_gettime(CLOCK_MONOTONIC, &tend);
printf("the computation took about %.15f seconds\n",
(((double)tend.tv_sec + 1e-9 * tend.tv_nsec) -
((double)tstart.tv_sec + 1e-9 * tstart.tv_nsec)) /
NUM_TIMES);
printf("%lf\n", s);
return 0;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment