Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Frederic Petrot
3a-archi
Commits
904111e0
Commit
904111e0
authored
Jan 30, 2020
by
Frederic Petrot
Browse files
Add calls to rdtsc to get accurate timings
parent
d6cdec67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
TP/tp-simd/sources/screen.c
TP/tp-simd/sources/screen.c
+6
-6
TP/tp-simd/sources/screen.o
TP/tp-simd/sources/screen.o
+0
-0
No files found.
TP/tp-simd/sources/screen.c
View file @
904111e0
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
******************************************************************************/
******************************************************************************/
#include "stdio.h"
#include "stdio.h"
#include "stdlib.h"
#include "stdlib.h"
#include "x86intrin.h"
#include "SDL/SDL.h"
#include "SDL/SDL.h"
#include "define_common.h"
#include "define_common.h"
...
@@ -115,13 +116,14 @@ void screen_cpyrect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, void *ptr)
...
@@ -115,13 +116,14 @@ void screen_cpyrect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, void *ptr)
int
screen_refresh
()
int
screen_refresh
()
{
{
SDL_Rect
offset
;
SDL_Rect
offset
;
uint64_t
new_time
,
finish_time
;
uint64_t
new_time
;
static
uint64_t
finish_clock
,
old_clock
;
SDL_Event
event
;
SDL_Event
event
;
offset
.
x
=
0
;
offset
.
x
=
0
;
offset
.
y
=
0
;
offset
.
y
=
0
;
SDL_BlitSurface
(
image
,
&
offset
,
screen
,
&
offset
)
;
SDL_BlitSurface
(
image
,
&
offset
,
screen
,
&
offset
)
;
new_time
=
SDL_GetTicks
()
;
new_time
=
SDL_GetTicks
()
;
finish_
time
=
SDL_GetTicks
()
;
finish_
clock
=
_rdtsc
()
;
while
(
new_time
-
old_time
<
1000
/
25
)
{
while
(
new_time
-
old_time
<
1000
/
25
)
{
new_time
=
SDL_GetTicks
()
;
new_time
=
SDL_GetTicks
()
;
}
}
...
@@ -129,8 +131,9 @@ int screen_refresh()
...
@@ -129,8 +131,9 @@ int screen_refresh()
printf
(
"Could not refresh screen: %s
\n
."
,
SDL_GetError
()
);
printf
(
"Could not refresh screen: %s
\n
."
,
SDL_GetError
()
);
}
}
IPRINTF
(
"[screen]: instantaneous fps is %0.2f
\n
"
,
1000
.
00
f
/
(
SDL_GetTicks
()
-
old_time
))
;
IPRINTF
(
"[screen]: instantaneous fps is %0.2f
\n
"
,
1000
.
00
f
/
(
SDL_GetTicks
()
-
old_time
))
;
printf
(
"[screen] : framerate is %0.2ffps, computed one image in %
0.2fm
s
\n
"
,
1000
.
00
f
/
(
SDL_GetTicks
()
-
old_time
),
(
finish_
time
-
old_
time
)
*
1
.
00
f
)
;
printf
(
"[screen] : framerate is %0.2ffps, computed one image in %
lu clock cycle
s
\n
"
,
1000
.
00
f
/
(
SDL_GetTicks
()
-
old_time
),
finish_
clock
-
old_
clock
)
;
old_time
=
SDL_GetTicks
()
;
old_time
=
SDL_GetTicks
()
;
old_clock
=
_rdtsc
()
;
// In this case, SDL is
// In this case, SDL is
if
(
SDL_PollEvent
(
&
event
))
{
if
(
SDL_PollEvent
(
&
event
))
{
if
(
event
.
type
==
SDL_QUIT
)
{
if
(
event
.
type
==
SDL_QUIT
)
{
...
@@ -141,6 +144,3 @@ int screen_refresh()
...
@@ -141,6 +144,3 @@ int screen_refresh()
}
}
return
0
;
return
0
;
}
}
TP/tp-simd/sources/screen.o
0 → 100644
View file @
904111e0
File added
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