Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
codecritic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ziyuan Nan
codecritic
Commits
d0f8150e
Commit
d0f8150e
authored
Sep 27, 2024
by
nanziyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
step1: evaluate_code improve multiprocess performance with imap_unordered and chunksize
parent
2b493df5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
step1_evaluate_code.py
+4
-4
No files found.
step1_evaluate_code.py
View file @
d0f8150e
...
@@ -3,13 +3,11 @@
...
@@ -3,13 +3,11 @@
import
json
import
json
import
multiprocessing
import
multiprocessing
from
multiprocessing
import
Pool
import
numpy
as
np
import
numpy
as
np
from
typing
import
Dict
from
typing
import
Dict
from
datasets
import
load_dataset
from
datasets
import
load_dataset
from
tqdm
import
tqdm
from
tqdm.contrib.concurrent
import
process_map
from
step1_apps_test
import
run_test
from
step1_apps_test
import
run_test
from
utils
import
extract_code
,
read_config
,
load_jsonl
,
save_jsonl
from
utils
import
extract_code
,
read_config
,
load_jsonl
,
save_jsonl
...
@@ -85,7 +83,9 @@ def evaluate_code_samples(code_samples: list, dataset_path: str):
...
@@ -85,7 +83,9 @@ def evaluate_code_samples(code_samples: list, dataset_path: str):
args
=
[(
get_apps_item
(
sample
),
sample
)
for
sample
in
code_samples
]
args
=
[(
get_apps_item
(
sample
),
sample
)
for
sample
in
code_samples
]
cpu_num
=
multiprocessing
.
cpu_count
()
cpu_num
=
multiprocessing
.
cpu_count
()
results
=
process_map
(
test_generation
,
args
,
max_workers
=
cpu_num
)
with
Pool
(
processes
=
cpu_num
)
as
pool
:
results
=
list
(
pool
.
imap_unordered
(
test_generation
,
args
,
chunksize
=
1000
))
return
results
return
results
...
...
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