Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tp2 hachage
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
Tristan Tolentino
tp2 hachage
Commits
fc94aff5
Commit
fc94aff5
authored
1 month ago
by
Tristan TOLENTINO
Browse files
Options
Downloads
Patches
Plain Diff
question 3, 4, 5
parent
ba9590c7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tp_2_miso_dict.py
+26
-9
26 additions, 9 deletions
tp_2_miso_dict.py
with
26 additions
and
9 deletions
tp_2_miso_dict.py
+
26
−
9
View file @
fc94aff5
...
...
@@ -14,21 +14,38 @@ def experiment_load_factor(load_factors):
insertion_times
=
[]
search_times
=
[]
deletion_times
=
[]
num_resizes
=
[]
sizes
=
[]
for
load_factor
in
load_factors
:
d
=
{}
d
=
{}
# Dictionnaire vide
size
=
int
(
10000
*
load_factor
)
# Taille de la structure en fonction du facteur charge
# Mesure du temps d'insertion
start_time
=
time
.
time
()
num_elements
=
0
# Nombre d'éléments
num_resize
=
0
# Nombre de réallocations de mémoire
last_size
=
sys
.
getsizeof
(
d
)
# Taille initiale du dictionnaire
start_time
=
time
.
time
()
# Mesure du temps d'insertion
# Insertion des éléments dans le dictionnaire
for
i
in
range
(
size
):
key
=
str
(
i
)
value
=
i
d
[
key
]
=
value
insertion_time
=
time
.
time
()
-
start_time
insertion_times
.
append
(
insertion_time
)
value
=
i
d
[
key
]
=
value
num_elements
+=
1
# Vérifier le nombre de réallocations mémoire
current_resize
=
sys
.
getsizeof
(
d
)
if
current_resize
>
last_size
:
num_resize
+=
1
last_size
=
current_resize
insertion_time
=
time
.
time
()
-
start_time
insertion_times
.
append
(
insertion_time
)
num_resizes
.
append
(
num_resize
)
sizes
.
append
(
last_size
)
# Mesure du temps de recherche
start_time
=
time
.
time
()
for
i
in
range
(
size
):
...
...
@@ -49,7 +66,7 @@ def experiment_load_factor(load_factors):
deletion_time
=
time
.
time
()
-
start_time
deletion_times
.
append
(
deletion_time
)
return
insertion_times
,
search_times
,
deletion_times
return
insertion_times
,
search_times
,
deletion_times
,
num_resizes
,
sizes
def
experiment_longest
():
...
...
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