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

dates

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