Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
P1_ESI_RubenGarciaVazquez
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
rubegar
P1_ESI_RubenGarciaVazquez
Commits
91a3f13f
Commit
91a3f13f
authored
8 months ago
by
rubegar
Browse files
Options
Downloads
Patches
Plain Diff
Delete media.py
parent
731bd095
No related branches found
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
media.py
+0
-35
0 additions, 35 deletions
media.py
with
0 additions
and
35 deletions
media.py
deleted
100644 → 0
+
0
−
35
View file @
731bd095
import
csv
from
collections
import
defaultdict
def
calculate_average_elapsed
(
csv_file
):
# Diccionario para almacenar la suma y el recuento de "elapsed" para cada "threadName"
sums_and_counts
=
defaultdict
(
lambda
:
[
0
,
0
])
# Leer el archivo CSV
with
open
(
csv_file
,
'
r
'
)
as
file
:
reader
=
csv
.
DictReader
(
file
)
# Omitir la primera fila (encabezados)
next
(
reader
)
# Iterar sobre las filas restantes
for
row
in
reader
:
threadName
=
row
[
'
threadName
'
]
elapsed
=
int
(
row
[
'
elapsed
'
])
# Actualizar la suma y el recuento para el "threadName" actual
sums_and_counts
[
threadName
][
0
]
+=
elapsed
sums_and_counts
[
threadName
][
1
]
+=
1
# Calcular la media de "elapsed" para cada "threadName"
averages
=
{
threadName
:
sums_and_counts
[
threadName
][
0
]
/
sums_and_counts
[
threadName
][
1
]
for
threadName
in
sums_and_counts
}
# Escribir los resultados en un nuevo archivo CSV
with
open
(
'
medPeque.csv
'
,
'
w
'
,
newline
=
''
)
as
file
:
writer
=
csv
.
writer
(
file
)
writer
.
writerow
([
'
threadName
'
,
'
average_elapsed
'
])
averages
=
sorted
(
averages
.
items
(),
key
=
lambda
x
:
x
[
0
])
for
threadName
,
average_elapsed
in
averages
:
writer
.
writerow
([
threadName
,
average_elapsed
])
calculate_average_elapsed
(
'
medidasPeque.csv
'
)
\ No newline at end of file
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