Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
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
Harbor 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
dCache
cta
Commits
5c4947dd
Commit
5c4947dd
authored
10 years ago
by
Giuseppe Lo Presti
Browse files
Options
Downloads
Patches
Plain Diff
Faster implementation of the number generator
parent
e5e47ef8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/stressTest/c2stress.cpp
+15
-8
15 additions, 8 deletions
test/stressTest/c2stress.cpp
with
15 additions
and
8 deletions
test/stressTest/c2stress.cpp
+
15
−
8
View file @
5c4947dd
...
...
@@ -187,11 +187,18 @@ int unlinkFile(const std::string &filepath,
// RandAlnum (Helper)
// Credit: http://stackoverflow.com/questions/440133/how-do-i-create-a-random-alpha-numeric-string-in-c
//-----------------------------------------------------------------------------
char
randAlnum
()
{
char
c
;
while
(
!
std
::
isalnum
(
c
=
static_cast
<
char
>
(
std
::
rand
())));
return
c
;
}
struct
randAlnum
{
randAlnum
(
char
const
*
range
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
)
:
range
(
range
),
len
(
std
::
strlen
(
range
))
{
}
char
operator
()()
const
{
return
range
[
static_cast
<
std
::
size_t
>
(
std
::
rand
()
*
(
1.0
/
(
RAND_MAX
+
1.0
))
*
len
)];
}
private
:
char
const
*
range
;
std
::
size_t
len
;
};
//-----------------------------------------------------------------------------
// ReadFileUsingRFIO
...
...
@@ -316,7 +323,7 @@ int writeFileUsingRFIO(const std::string &filepath,
buffer
+=
" "
;
// The rest of the buffer should contain random data
generate_n
(
std
::
back_inserter
(
buffer
),
bufsize
-
buffer
.
length
(),
randAlnum
);
generate_n
(
std
::
back_inserter
(
buffer
),
bufsize
-
buffer
.
length
(),
randAlnum
()
);
// Write the first buffer
int64_t
bytessent
=
0
;
...
...
@@ -342,7 +349,7 @@ int writeFileUsingRFIO(const std::string &filepath,
if
(
bufsize
>
(
fileSize
-
bytessent
))
{
bufsize
=
(
fileSize
-
bytessent
);
}
generate_n
(
std
::
back_inserter
(
buffer
),
bufsize
,
randAlnum
);
generate_n
(
std
::
back_inserter
(
buffer
),
bufsize
,
randAlnum
()
);
// Write the second buffer to the file until we reach the desired fileSize or
// an error is encountered.
...
...
@@ -475,7 +482,7 @@ int writeFileUsingXROOTD(const std::string &filepath,
buffer
.
reserve
(
bufsize
);
// The buffer should contain random data
generate_n
(
std
::
back_inserter
(
buffer
),
bufsize
-
buffer
.
length
(),
randAlnum
);
generate_n
(
std
::
back_inserter
(
buffer
),
bufsize
-
buffer
.
length
(),
randAlnum
()
);
XrdCl
::
File
f
;
XrdCl
::
XRootDStatus
status
;
...
...
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