Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
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
go
Commits
86c0c54d
Commit
86c0c54d
authored
Dec 07, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/bench: faster fasta (mostly due to bufio fix)
R=r
https://golang.org/cl/165083
parent
0d3301a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
18 deletions
+16
-18
test/bench/fasta.go
test/bench/fasta.go
+16
-18
No files found.
test/bench/fasta.go
View file @
86c0c54d
...
...
@@ -62,20 +62,6 @@ type AminoAcid struct {
c
byte
;
}
var
lastrandom
uint32
=
42
// Random number between 0.0 and 1.0
func
myrandom
()
float
{
const
(
IM
=
139968
;
IA
=
3877
;
IC
=
29573
;
)
lastrandom
=
(
lastrandom
*
IA
+
IC
)
%
IM
;
// Integer to float conversions are faster if the integer is signed.
return
float
(
int32
(
lastrandom
))
/
IM
;
}
func
AccumulateProbabilities
(
genelist
[]
AminoAcid
)
{
for
i
:=
1
;
i
<
len
(
genelist
);
i
++
{
genelist
[
i
]
.
p
+=
genelist
[
i
-
1
]
.
p
...
...
@@ -104,6 +90,14 @@ func RepeatFasta(s []byte, count int) {
}
}
var
lastrandom
uint32
=
42
const
(
IM
=
139968
;
IA
=
3877
;
IC
=
29573
;
)
// Each element of genelist is a struct with a character and
// a floating point number p between 0 and 1.
// RandomFasta generates a random float r and
...
...
@@ -117,11 +111,15 @@ func RandomFasta(genelist []AminoAcid, count int) {
for
count
>
0
{
line
:=
min
(
WIDTH
,
count
);
for
pos
:=
0
;
pos
<
line
;
pos
++
{
r
:=
myrandom
();
var
i
int
;
for
i
=
0
;
genelist
[
i
]
.
p
<
r
;
i
++
{
lastrandom
=
(
lastrandom
*
IA
+
IC
)
%
IM
;
// Integer to float conversions are faster if the integer is signed.
r
:=
float
(
int32
(
lastrandom
))
/
IM
;
for
_
,
v
:=
range
genelist
{
if
v
.
p
>=
r
{
buf
[
pos
]
=
v
.
c
;
break
;
}
}
buf
[
pos
]
=
genelist
[
i
]
.
c
;
}
buf
[
line
]
=
'\n'
;
out
.
Write
(
buf
[
0
:
line
+
1
]);
...
...
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