Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
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
beego
Commits
c8c25549
Commit
c8c25549
authored
Sep 07, 2017
by
wangguoliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
should use time.Since instead of time.Now().Sub
Signed-off-by:
wgliang
<
liangcszzu@163.com
>
parent
d96289a8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7 additions
and
7 deletions
+7
-7
memory.go
cache/memory.go
+1
-1
options.go
context/param/options.go
+1
-1
parsers_test.go
context/param/parsers_test.go
+1
-1
orm_log.go
orm/orm_log.go
+1
-1
parser.go
parser.go
+1
-1
profile.go
toolbox/profile.go
+2
-2
No files found.
cache/memory.go
View file @
c8c25549
...
...
@@ -38,7 +38,7 @@ func (mi *MemoryItem) isExpire() bool {
if
mi
.
lifespan
==
0
{
return
false
}
return
time
.
Now
()
.
Sub
(
mi
.
createdTime
)
>
mi
.
lifespan
return
time
.
Since
(
mi
.
createdTime
)
>
mi
.
lifespan
}
// MemoryCache is Memory cache adapter.
...
...
context/param/options.go
View file @
c8c25549
...
...
@@ -7,7 +7,7 @@ import (
// MethodParamOption defines a func which apply options on a MethodParam
type
MethodParamOption
func
(
*
MethodParam
)
// IsRequired indicates that this param is required and can not be om
mi
ted from the http request
// IsRequired indicates that this param is required and can not be om
it
ted from the http request
var
IsRequired
MethodParamOption
=
func
(
p
*
MethodParam
)
{
p
.
required
=
true
}
...
...
context/param/parsers_test.go
View file @
c8c25549
...
...
@@ -75,7 +75,7 @@ func checkParser(def testDefinition, t *testing.T, methodParam ...MethodParam) {
}
convResult
,
err
:=
safeConvert
(
reflect
.
ValueOf
(
result
),
toType
)
if
err
!=
nil
{
t
.
Errorf
(
"Conver
t
ion error for %v. from value: %v, toType: %v, error: %v"
,
def
.
strValue
,
result
,
toType
,
err
)
t
.
Errorf
(
"Conver
s
ion error for %v. from value: %v, toType: %v, error: %v"
,
def
.
strValue
,
result
,
toType
,
err
)
return
}
if
!
reflect
.
DeepEqual
(
convResult
.
Interface
(),
def
.
expectedValue
)
{
...
...
orm/orm_log.go
View file @
c8c25549
...
...
@@ -36,7 +36,7 @@ func NewLog(out io.Writer) *Log {
}
func
debugLogQueies
(
alias
*
alias
,
operaton
,
query
string
,
t
time
.
Time
,
err
error
,
args
...
interface
{})
{
sub
:=
time
.
Now
()
.
Sub
(
t
)
/
1e5
sub
:=
time
.
Since
(
t
)
/
1e5
elsp
:=
float64
(
int
(
sub
))
/
10.0
flag
:=
" OK"
if
err
!=
nil
{
...
...
parser.go
View file @
c8c25549
...
...
@@ -227,7 +227,7 @@ func parseComment(lines []*ast.Comment) (pc *parsedComment, err error) {
}
// direct copy from bee\g_docs.go
// anal
isy
s params return []string
// anal
ysi
s params return []string
// @Param query form string true "The email for login"
// [query form string true "The email for login"]
func
getparams
(
str
string
)
[]
string
{
...
...
toolbox/profile.go
View file @
c8c25549
...
...
@@ -106,7 +106,7 @@ func printGC(memStats *runtime.MemStats, gcstats *debug.GCStats, w io.Writer) {
if
gcstats
.
NumGC
>
0
{
lastPause
:=
gcstats
.
Pause
[
0
]
elapsed
:=
time
.
Now
()
.
Sub
(
startTime
)
elapsed
:=
time
.
Since
(
startTime
)
overhead
:=
float64
(
gcstats
.
PauseTotal
)
/
float64
(
elapsed
)
*
100
allocatedRate
:=
float64
(
memStats
.
TotalAlloc
)
/
elapsed
.
Seconds
()
...
...
@@ -123,7 +123,7 @@ func printGC(memStats *runtime.MemStats, gcstats *debug.GCStats, w io.Writer) {
toS
(
gcstats
.
PauseQuantiles
[
99
]))
}
else
{
// while GC has disabled
elapsed
:=
time
.
Now
()
.
Sub
(
startTime
)
elapsed
:=
time
.
Since
(
startTime
)
allocatedRate
:=
float64
(
memStats
.
TotalAlloc
)
/
elapsed
.
Seconds
()
fmt
.
Fprintf
(
w
,
"Alloc:%s Sys:%s Alloc(Rate):%s/s
\n
"
,
...
...
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