Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioping
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ioping
Commits
aa2558ce
Commit
aa2558ce
authored
Dec 29, 2015
by
Konstantin Khlebnikov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ioping: use xorshift128+ for randomization
Signed-off-by:
Konstantin Khlebnikov
<
koct9i@gmail.com
>
parent
37608312
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
ioping.c
ioping.c
+32
-16
No files found.
ioping.c
View file @
aa2558ce
...
...
@@ -963,24 +963,40 @@ void set_signal(void)
#endif
/* __MINGW32__ */
void
random_memory
(
void
*
buf
,
size_t
len
)
static
unsigned
long
long
random_state
[
2
];
/* xorshift128+ */
static
inline
unsigned
long
long
random64
(
void
)
{
unsigned
char
*
ptr
=
buf
;
size_t
i
;
unsigned
long
long
s1
=
random_state
[
0
];
const
unsigned
long
long
s0
=
random_state
[
1
];
random_state
[
0
]
=
s0
;
s1
^=
s1
<<
23
;
// a
random_state
[
1
]
=
s1
^
s0
^
(
s1
>>
17
)
^
(
s0
>>
26
);
// b, c
return
random_state
[
1
]
+
s0
;
}
for
(
i
=
0
;
i
<
len
;
i
++
)
ptr
[
i
]
=
random
();
static
void
random_init
(
void
)
{
srandom
(
now
());
random_state
[
0
]
=
random
();
random_state
[
1
]
=
random
();
(
void
)
random64
();
(
void
)
random64
();
}
/* not so random but much faster */
void
shake_memory
(
void
*
buf
,
size_t
len
)
static
void
random_memory
(
void
*
buf
,
size_t
len
)
{
unsigned
int
*
ptr
=
buf
;
unsigned
int
word
=
random
();
size_t
i
;
unsigned
long
long
*
ptr
=
buf
;
size_t
words
=
len
>>
3
;
while
(
words
--
)
*
ptr
++
=
random64
();
for
(
i
=
0
,
len
/=
4
;
i
<
len
;
i
++
)
ptr
[
i
]
^=
word
;
if
(
len
&
7
)
{
unsigned
long
long
last
=
random64
();
memcpy
(
ptr
,
&
last
,
len
&
7
);
}
}
int
main
(
int
argc
,
char
**
argv
)
...
...
@@ -1094,6 +1110,8 @@ int main (int argc, char **argv)
if
(
ret
)
errx
(
2
,
"buffer allocation failed"
);
random_init
();
random_memory
(
buf
,
size
);
if
(
S_ISDIR
(
st
.
st_mode
))
{
...
...
@@ -1141,8 +1159,6 @@ skip_preparation:
#endif
}
srandom
(
now
());
if
(
deadline
)
deadline
+=
now
();
...
...
@@ -1168,7 +1184,7 @@ skip_preparation:
part_request
++
;
if
(
randomize
)
woffset
=
random
()
%
(
wsize
/
size
)
*
size
;
woffset
=
random
64
()
%
(
wsize
/
size
)
*
size
;
#ifdef HAVE_POSIX_FADVICE
if
(
!
cached
)
{
...
...
@@ -1180,7 +1196,7 @@ skip_preparation:
#endif
if
(
write_test
)
shake
_memory
(
buf
,
size
);
random
_memory
(
buf
,
size
);
this_time
=
now
();
...
...
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