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
1504e701
Verified
Commit
1504e701
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: support for chunk size for clock_m usage
parent
63ae53b6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#2822
failed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontends/sdl/src/main.rs
+13
-5
13 additions, 5 deletions
frontends/sdl/src/main.rs
src/gb.rs
+7
-1
7 additions, 1 deletion
src/gb.rs
with
20 additions
and
6 deletions
frontends/sdl/src/main.rs
+
13
−
5
View file @
1504e701
...
...
@@ -39,17 +39,18 @@ const VOLUME: f32 = 64.0;
pub
struct
Benchmark
{
count
:
usize
,
chunk_size
:
Option
<
usize
>
,
}
impl
Benchmark
{
pub
fn
new
(
count
:
usize
)
->
Self
{
Self
{
count
}
pub
fn
new
(
count
:
usize
,
chunk_size
:
Option
<
usize
>
)
->
Self
{
Self
{
count
,
chunk_size
}
}
}
impl
Default
for
Benchmark
{
fn
default
()
->
Self
{
Self
::
new
(
50000000
)
Self
::
new
(
50000000
,
None
)
}
}
...
...
@@ -224,12 +225,19 @@ impl Emulator {
println!
(
"Going to run benchmark..."
);
let
count
=
params
.count
;
let
chunk_size
=
params
.chunk_size
.unwrap_or
(
1
);
let
mut
cycles
=
0
;
let
initial
=
SystemTime
::
now
();
for
_
in
0
..
count
{
cycles
+=
self
.system
.clock
()
as
u32
;
if
chunk_size
>
1
{
for
_
in
0
..
(
count
/
chunk_size
)
{
cycles
+=
self
.system
.clock_m
(
chunk_size
)
as
u32
;
}
}
else
{
for
_
in
0
..
count
{
cycles
+=
self
.system
.clock
()
as
u32
;
}
}
let
delta
=
initial
.elapsed
()
.unwrap
()
.as_millis
()
as
f32
/
1000.0
;
...
...
This diff is collapsed.
Click to expand it.
src/gb.rs
+
7
−
1
View file @
1504e701
...
...
@@ -412,10 +412,16 @@ impl GameBoy {
cycles
}
/// Risky function that will clock the CPU multiple times
/// allowing an undefined number of cycles to be executed
/// in the other Game Boy components.
/// This can cause unwanted behaviour in components like
/// the PPU where only one mode switch operation is expected
/// per each clock call.
pub
fn
clock_m
(
&
mut
self
,
count
:
usize
)
->
u16
{
let
mut
cycles
=
0u16
;
for
_
in
0
..
count
{
cycles
+=
self
.clock
()
as
u16
;
cycles
+=
self
.
cpu_
clock
()
as
u16
;
}
let
cycles_n
=
cycles
/
self
.multiplier
()
as
u16
;
if
self
.ppu_enabled
{
...
...
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