Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
3441bda9
Commit
3441bda9
authored
Apr 14, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gotest: add timing, respect $GOARCH
R=r, r2 CC=golang-dev
https://golang.org/cl/4370049
parent
bd43a2d9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
gotest.go
src/cmd/gotest/gotest.go
+20
-1
No files found.
src/cmd/gotest/gotest.go
View file @
3441bda9
...
...
@@ -16,6 +16,7 @@ import (
"path/filepath"
"runtime"
"strings"
"time"
"unicode"
"utf8"
)
...
...
@@ -51,6 +52,13 @@ var (
xFlag
bool
)
// elapsed returns time elapsed since gotest started.
func
elapsed
()
float64
{
return
float64
(
time
.
Nanoseconds
()
-
start
)
/
1e9
}
var
start
=
time
.
Nanoseconds
()
// File represents a file that contains tests.
type
File
struct
{
name
string
...
...
@@ -80,6 +88,9 @@ func main() {
if
!
cFlag
{
runTestWithArgs
(
"./"
+
O
+
".out"
)
}
if
xFlag
{
fmt
.
Printf
(
"gotest %.2fs: done
\n
"
,
elapsed
())
}
}
// needMakefile tests that we have a Makefile in this directory.
...
...
@@ -119,7 +130,10 @@ func setEnvironment() {
// Basic environment.
GOROOT
=
runtime
.
GOROOT
()
addEnv
(
"GOROOT"
,
GOROOT
)
GOARCH
=
os
.
Getenv
(
"GOARCH"
)
if
GOARCH
==
""
{
GOARCH
=
runtime
.
GOARCH
}
addEnv
(
"GOARCH"
,
GOARCH
)
O
=
theChar
[
GOARCH
]
if
O
==
""
{
...
...
@@ -254,7 +268,12 @@ func runTestWithArgs(binary string) {
// retrieve standard output.
func
doRun
(
argv
[]
string
,
returnStdout
bool
)
string
{
if
xFlag
{
fmt
.
Printf
(
"gotest: %s
\n
"
,
strings
.
Join
(
argv
,
" "
))
fmt
.
Printf
(
"gotest %.2fs: %s
\n
"
,
elapsed
(),
strings
.
Join
(
argv
,
" "
))
t
:=
-
time
.
Nanoseconds
()
defer
func
()
{
t
+=
time
.
Nanoseconds
()
fmt
.
Printf
(
" [+%.2fs]
\n
"
,
float64
(
t
)
/
1e9
)
}()
}
command
:=
argv
[
0
]
if
runtime
.
GOOS
==
"windows"
&&
command
==
"gomake"
{
...
...
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