Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cours
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
joachim.bach
cours
Commits
f8722d81
Verified
Commit
f8722d81
authored
3 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
updated path for complexity slides
parent
85e79812
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
slides/complexite.md
+23
-6
23 additions, 6 deletions
slides/complexite.md
with
23 additions
and
6 deletions
slides/complexite.md
+
23
−
6
View file @
f8722d81
...
...
@@ -13,19 +13,36 @@ Comment mesurer l'efficacité d'un algorithme?
Dépendant du
**matériel**
, du
**compilateur**
, des
**options de compilation**
,
etc!
##
Exemple: somme d'entiers
##
Mesure du temps CPU
```
C
#include <time.h>
struct timespec tstart={0,0}, tend={0,0};
clock_gettime(CLOCK_MONOTONIC, &tstart);
// some computation
clock_gettime(CLOCK_MONOTONIC, &tend);
printf("computation about %.5f seconds\n",
((double)tend.tv_sec + 1e-9*tend.tv_nsec) -
((double)tstart.tv_sec + 1e-9*tstart.tv_nsec));
```
# Programme simple: mesure du temps CPU
printf("some_long_computation took about %.5f seconds\n",
((double)tend.tv_sec + 1.0e-9*tend.tv_nsec) -
((double)tstart.tv_sec + 1.0e-9*tstart.tv_nsec));
## Preuve sur un [petit exemple](../source_codes/complexity/sum.c)
```
bash
source_codes/complexity
$
make bench
RUN ONCE O0
the computation of 199972.740622 took about 0.00836 seconds
RUN ONCE O3
the computation of 199972.740622 took about 0.00203 seconds
RUN THOUSAND TIMES O0
the computation of 199972740.621922 took about 0.00363 seconds
RUN THOUSAND TIMES O3
the computation of 199972740.621922 took about 0.00046 seconds
```
*
Il est nécessaire d'avoir une mesure indépendante du matériel.
. . .
*
Il est nécessaire d'avoir une mesure indépendante du
matériel/compilateur/façon de mesurer.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment