Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Nadi Tomeh
SDA
Commits
5010fdaf
Commit
5010fdaf
authored
Sep 17, 2019
by
david
Browse files
modified measure of time CPP
parent
b7799206
Changes
2
Hide whitespace changes
Inline
Side-by-side
CPP/Makefile
View file @
5010fdaf
...
...
@@ -10,3 +10,7 @@ clean:
rm
-rf
*
.o
rm
-rf
*
~
rm
-rf
arraylist_analysis
%.o
:
%.cpp
$(CC)
$(CPPFLAGS)
-c
$<
-o
$@
CPP/main.cpp
View file @
5010fdaf
#include<iostream>
#include
<time.h
>
#include
<chrono
>
#include<cstdlib>
#include "arraylist.hpp"
#include "analyzer.hpp"
using
namespace
std
::
chrono
;
int
main
(
int
argc
,
char
**
argv
){
int
i
;
// Tableau dynamique.
...
...
@@ -15,18 +18,19 @@ int main(int argc, char ** argv){
Analyzer
copy_analysis
;
// Analyse de l'espace mémoire inutilisé.
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
memory_allocation
;
for
(
i
=
0
;
i
<
1000000
;
i
++
){
// 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
);
timespec_get
(
&
after
,
TIME_UTC
);
after
=
high_resolution_clock
::
now
(
);
// 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.
// S'il y a eu réallocation de mémoire, il a fallu recopier tout le tableau.
copy_analysis
.
append
(
(
memory_allocation
)
?
i
:
1
);
...
...
@@ -47,3 +51,4 @@ int main(int argc, char ** argv){
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment