Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
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
Container 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
João Magalhães
boytacean
Commits
1fd28828
Verified
Commit
1fd28828
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: new benchmark modes
parent
04808c1a
No related branches found
No related tags found
1 merge request
!24
Performance optimisations
Pipeline
#2833
passed
1 year ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.github/workflows/main.yml
+2
-0
2 additions, 0 deletions
.github/workflows/main.yml
frontends/sdl/src/main.rs
+32
-7
32 additions, 7 deletions
frontends/sdl/src/main.rs
src/gb.rs
+8
-0
8 additions, 0 deletions
src/gb.rs
with
42 additions
and
7 deletions
.github/workflows/main.yml
+
2
−
0
View file @
1fd28828
...
...
@@ -129,3 +129,5 @@ jobs:
run
:
cd frontends/sdl && cargo run --release -- --headless --cycles
10000000
-
name
:
Run benchmark
run
:
cd frontends/sdl && cargo run --release -- --benchmark
-
name
:
Run benchmark, only for CPU
run
:
cd frontends/sdl && cargo run --release -- --benchmark --cpu-only
This diff is collapsed.
Click to expand it.
frontends/sdl/src/main.rs
+
32
−
7
View file @
1fd28828
...
...
@@ -40,17 +40,22 @@ const VOLUME: f32 = 64.0;
pub
struct
Benchmark
{
count
:
usize
,
chunk_size
:
Option
<
usize
>
,
cpu_only
:
Option
<
bool
>
,
}
impl
Benchmark
{
pub
fn
new
(
count
:
usize
,
chunk_size
:
Option
<
usize
>
)
->
Self
{
Self
{
count
,
chunk_size
}
pub
fn
new
(
count
:
usize
,
cpu_only
:
Option
<
bool
>
,
chunk_size
:
Option
<
usize
>
)
->
Self
{
Self
{
count
,
cpu_only
,
chunk_size
,
}
}
}
impl
Default
for
Benchmark
{
fn
default
()
->
Self
{
Self
::
new
(
50000000
,
None
)
Self
::
new
(
50000000
,
None
,
None
)
}
}
...
...
@@ -221,13 +226,18 @@ impl Emulator {
self
.load_rom
(
None
);
}
pub
fn
benchmark
(
&
mut
self
,
params
:
Benchmark
)
{
pub
fn
benchmark
(
&
mut
self
,
params
:
&
Benchmark
)
{
println!
(
"Going to run benchmark..."
);
let
count
=
params
.count
;
let
chunk_size
=
params
.chunk_size
.unwrap_or
(
1
);
let
cpu_only
=
params
.cpu_only
.unwrap_or
(
false
);
let
mut
cycles
=
0u64
;
if
cpu_only
{
self
.system
.set_all_enabled
(
false
);
}
let
initial
=
SystemTime
::
now
();
if
chunk_size
>
1
{
...
...
@@ -320,7 +330,7 @@ impl Emulator {
Event
::
KeyDown
{
keycode
:
Some
(
Keycode
::
B
),
..
}
=>
self
.benchmark
(
Benchmark
::
default
()),
}
=>
self
.benchmark
(
&
Benchmark
::
default
()),
Event
::
KeyDown
{
keycode
:
Some
(
Keycode
::
T
),
..
...
...
@@ -491,11 +501,16 @@ impl Emulator {
}
}
pub
fn
run_benchmark
(
&
mut
self
,
params
:
Benchmark
)
{
pub
fn
run_benchmark
(
&
mut
self
,
params
:
&
Benchmark
)
{
let
count
=
params
.count
;
let
chunk_size
=
params
.chunk_size
.unwrap_or
(
1
);
let
cpu_only
=
params
.cpu_only
.unwrap_or
(
false
);
let
mut
cycles
=
0u64
;
if
cpu_only
{
self
.system
.set_all_enabled
(
false
);
}
let
initial
=
SystemTime
::
now
();
if
chunk_size
>
1
{
...
...
@@ -640,6 +655,16 @@ struct Args {
)]
benchmark
:
bool
,
#[arg(
long,
default_value_t
=
500000000
,
help
=
"The size of the benchmark in clock ticks"
)]
bench_count
:
usize
,
#[arg(long,
default_value_t
=
false
,
help
=
"Run benchmark only for the CPU"
)]
cpu_only
:
bool
,
#[arg(
long,
default_value_t
=
false
,
...
...
@@ -711,7 +736,7 @@ fn main() {
// not and runs it accordingly, note that if running in headless
// mode the number of cycles to be run may be specified
if
args
.benchmark
{
emulator
.run_benchmark
(
Benchmark
::
new
(
500000000
,
None
));
emulator
.run_benchmark
(
&
Benchmark
::
new
(
args
.bench_count
,
Some
(
args
.cpu_only
)
,
None
));
}
else
if
args
.headless
{
emulator
.run_headless
(
if
args
.cycles
>
0
{
Some
(
args
.cycles
)
...
...
This diff is collapsed.
Click to expand it.
src/gb.rs
+
8
−
0
View file @
1fd28828
...
...
@@ -775,6 +775,14 @@ impl GameBoy {
(
*
self
.gbc
)
.borrow_mut
()
.set_serial_enabled
(
value
);
}
pub
fn
set_all_enabled
(
&
mut
self
,
value
:
bool
)
{
self
.set_ppu_enabled
(
value
);
self
.set_apu_enabled
(
value
);
self
.set_dma_enabled
(
value
);
self
.set_timer_enabled
(
value
);
self
.set_serial_enabled
(
value
);
}
pub
fn
clock_freq
(
&
self
)
->
u32
{
self
.clock_freq
}
...
...
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