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
5005fb46
Commit
5005fb46
authored
15 years ago
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify threadring slightly; slight speed improvement
R=rsc DELTA=7 (3 added, 3 deleted, 1 changed) OCL=32885 CL=32889
parent
aa7bd483
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
test/bench/threadring.go
test/bench/threadring.go
+4
-7
test/bench/timing.log
test/bench/timing.log
+3
-0
No files found.
test/bench/threadring.go
View file @
5005fb46
...
@@ -39,7 +39,6 @@ import (
...
@@ -39,7 +39,6 @@ import (
"flag"
;
"flag"
;
"fmt"
;
"fmt"
;
"os"
;
"os"
;
"time"
;
)
)
var
n
=
flag
.
Int
(
"n"
,
1000
,
"how many passes"
)
var
n
=
flag
.
Int
(
"n"
,
1000
,
"how many passes"
)
...
@@ -58,17 +57,15 @@ func f(i int, in <-chan int, out chan<- int) {
...
@@ -58,17 +57,15 @@ func f(i int, in <-chan int, out chan<- int) {
}
}
func
main
()
{
func
main
()
{
flag
.
Parse
();
flag
.
Parse
();
one
:=
make
(
chan
int
);
// will be input to thread 1
one
:=
make
(
chan
int
);
// will be input to thread 1
var
in
,
out
chan
int
=
nil
,
one
;
var
in
,
out
chan
int
=
nil
,
one
;
for
i
:=
1
;
i
<=
Nthread
-
1
;
i
++
{
for
i
:=
1
;
i
<=
Nthread
-
1
;
i
++
{
in
,
out
=
out
,
make
(
chan
int
);
in
,
out
=
out
,
make
(
chan
int
);
go
f
(
i
,
in
,
out
);
go
f
(
i
,
in
,
out
);
}
}
go
f
(
Nthread
,
out
,
one
);
go
f
(
Nthread
,
out
,
one
);
one
<-
*
n
;
one
<-
*
n
;
for
{
<-
make
(
chan
int
);
// hang until ring completes
time
.
Sleep
(
100
*
1e9
);
// wait for ring to run
}
}
}
This diff is collapsed.
Click to expand it.
test/bench/timing.log
View file @
5005fb46
...
@@ -120,3 +120,6 @@ threadring 50000000
...
@@ -120,3 +120,6 @@ threadring 50000000
gccgo -O2 threadring.go 90.33u 459.95s 448.03r
gccgo -O2 threadring.go 90.33u 459.95s 448.03r
gc threadring 33.11u 0.00s 33.14r
gc threadring 33.11u 0.00s 33.14r
GOMAXPROCS=4 gc threadring 114.48u 226.65s 371.59r
GOMAXPROCS=4 gc threadring 114.48u 226.65s 371.59r
# change wait code to do <-make(chan int) instead of time.Sleep
gc threadring 28.41u 0.01s 29.35r
GOMAXPROCS=4 gc threadring 112.59u 232.83s 384.72r
This diff is collapsed.
Click to expand it.
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