Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bpm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Yoann DUFRESNE
bpm
Commits
45069a9d
Commit
45069a9d
authored
7 years ago
by
Yoann Dufresne
Browse files
Options
Downloads
Patches
Plain Diff
speed test on hash then compare vs hash/compare on the fly
parent
a66f0803
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/speed_tests.c
+43
-1
43 additions, 1 deletion
src/speed_tests.c
with
43 additions
and
1 deletion
src/speed_tests.c
+
43
−
1
View file @
45069a9d
#include
<zlib.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdint.h>
#include
"fasta.h"
#define HASH_SIZE 32
#define letter_hash(letter) ((uint64_t)((letter & 0b100) ? (0b10 | ((~letter) & 0b01)) : ((letter >> 1) & 0b11)))
uint64_t
sliding_hash
(
seq_t
*
seq
)
{
uint64_t
hash
=
0
;
uint64_t
nothing
=
2135234
;
for
(
uint
idx
=
0
;
idx
<
32
;
idx
++
)
hash
=
(
hash
<<
2
)
|
letter_hash
(
seq
->
value
[
idx
]);
for
(
uint
idx
=
32
;
idx
<
seq
->
length
;
idx
++
)
{
hash
=
(
hash
<<
2
)
|
letter_hash
(
seq
->
value
[
idx
]);
// Do something with the hash to not allow compiler to delete the value.
nothing
-
hash
;
}
}
uint64_t
hash_then_compact
(
seq_t
*
seq
)
{
uint64_t
hash
=
0
;
uint64_t
nothing
=
2135234
;
// Hash letters
for
(
uint
idx
=
0
;
idx
<
seq
->
length
;
idx
++
)
{
seq
->
value
[
idx
]
=
letter_hash
(
seq
->
value
[
idx
]);
}
// compute 64 bits hashes
for
(
uint
idx
=
0
;
idx
<
32
;
idx
++
)
hash
=
(
hash
<<
2
)
|
seq
->
value
[
idx
];
for
(
uint
idx
=
32
;
idx
<
seq
->
length
;
idx
++
)
{
hash
=
(
hash
<<
2
)
|
seq
->
value
[
idx
];
// Do something with the hash to not allow compiler to delete the value.
nothing
-
hash
;
}
}
int
main
()
{
/* --- Load all the alleles --- */
...
...
@@ -13,8 +51,12 @@ int main () {
seq_t
*
alleles
;
buffer_t
*
buff
=
init_buffer
(
filename
);
uint
nb_seq
=
read_sequences
(
filename
,
&
alleles
,
buff
);
/* Speed test on hash function */
for
(
uint
idx
=
0
;
idx
<
nb_seq
;
idx
++
)
{
sliding_hash
(
alleles
+
idx
);
}
free
(
alleles
);
destroy_buffer
(
buff
);
...
...
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