Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SDA
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
Julien David
SDA
Commits
5010fdaf
Commit
5010fdaf
authored
5 years ago
by
david
Browse files
Options
Downloads
Patches
Plain Diff
modified measure of time CPP
parent
b7799206
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CPP/Makefile
+4
-0
4 additions, 0 deletions
CPP/Makefile
CPP/main.cpp
+10
-5
10 additions, 5 deletions
CPP/main.cpp
with
14 additions
and
5 deletions
CPP/Makefile
+
4
−
0
View file @
5010fdaf
...
@@ -10,3 +10,7 @@ clean:
...
@@ -10,3 +10,7 @@ clean:
rm
-rf
*
.o
rm
-rf
*
.o
rm
-rf
*
~
rm
-rf
*
~
rm
-rf
arraylist_analysis
rm
-rf
arraylist_analysis
%.o
:
%.cpp
$(
CC
)
$(
CPPFLAGS
)
-c
$<
-o
$@
This diff is collapsed.
Click to expand it.
CPP/main.cpp
+
10
−
5
View file @
5010fdaf
#include
<iostream>
#include
<iostream>
#include
<time.h
>
#include
<chrono
>
#include
<cstdlib>
#include
<cstdlib>
#include
"arraylist.hpp"
#include
"arraylist.hpp"
#include
"analyzer.hpp"
#include
"analyzer.hpp"
using
namespace
std
::
chrono
;
int
main
(
int
argc
,
char
**
argv
){
int
main
(
int
argc
,
char
**
argv
){
int
i
;
int
i
;
// Tableau dynamique.
// Tableau dynamique.
...
@@ -15,18 +18,19 @@ int main(int argc, char ** argv){
...
@@ -15,18 +18,19 @@ int main(int argc, char ** argv){
Analyzer
copy_analysis
;
Analyzer
copy_analysis
;
// Analyse de l'espace mémoire inutilisé.
// Analyse de l'espace mémoire inutilisé.
Analyzer
memory_analysis
;
Analyzer
memory_analysis
;
struct
timespec
before
,
after
;
high_resolution_clock
::
time_point
before
,
after
;
// Booléen permettant de savoir si une allocation a été effectuée.
// Booléen permettant de savoir si une allocation a été effectuée.
bool
memory_allocation
;
bool
memory_allocation
;
for
(
i
=
0
;
i
<
1000000
;
i
++
){
for
(
i
=
0
;
i
<
1000000
;
i
++
){
// Ajout d'un élément et mesure du temps pris par l'opération.
// Ajout d'un élément et mesure du temps pris par l'opération.
timespec_get
(
&
before
,
TIME_UTC
);
before
=
high_resolution_clock
::
now
(
);
memory_allocation
=
a
.
append
(
i
);
memory_allocation
=
a
.
append
(
i
);
timespec_get
(
&
after
,
TIME_UTC
);
after
=
high_resolution_clock
::
now
(
);
// Enregistrement du temps pris par l'opération
// Enregistrement du temps pris par l'opération
time_analysis
.
append
(
after
.
tv_nsec
-
before
.
tv_nsec
);
auto
duration
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
after
-
before
);
time_analysis
.
append
(
static_cast
<
double
>
(
duration
.
count
()));
// Enregistrement du nombre de copies efféctuées par l'opération.
// Enregistrement du nombre de copies efféctuées par l'opération.
// S'il y a eu réallocation de mémoire, il a fallu recopier tout le tableau.
// S'il y a eu réallocation de mémoire, il a fallu recopier tout le tableau.
copy_analysis
.
append
(
(
memory_allocation
)
?
i
:
1
);
copy_analysis
.
append
(
(
memory_allocation
)
?
i
:
1
);
...
@@ -47,3 +51,4 @@ int main(int argc, char ** argv){
...
@@ -47,3 +51,4 @@ int main(int argc, char ** argv){
return
0
;
return
0
;
}
}
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