Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
5ae8a836
Commit
5ae8a836
authored
6 years ago
by
vito.he
Browse files
Options
Downloads
Patches
Plain Diff
Del:remove benchmark
parent
518e8991
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/jsonrpc/go-client/benchmark/benchmark.go
+0
-160
0 additions, 160 deletions
examples/jsonrpc/go-client/benchmark/benchmark.go
examples/jsonrpc/go-client/benchmark/user.go
+0
-43
0 additions, 43 deletions
examples/jsonrpc/go-client/benchmark/user.go
with
0 additions
and
203 deletions
examples/jsonrpc/go-client/benchmark/benchmark.go
deleted
100644 → 0
+
0
−
160
View file @
518e8991
package
main
import
(
"context"
"errors"
"flag"
"github.com/dubbo/go-for-apache-dubbo/config"
"log"
"sync"
"sync/atomic"
"time"
)
import
(
"github.com/montanaflynn/stats"
)
import
(
_
"github.com/dubbo/go-for-apache-dubbo/protocol/jsonrpc"
_
"github.com/dubbo/go-for-apache-dubbo/registry/protocol"
_
"github.com/dubbo/go-for-apache-dubbo/filter/impl"
_
"github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance"
_
"github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl"
_
"github.com/dubbo/go-for-apache-dubbo/registry/zookeeper"
)
// they are necessary:
// export CONF_CONSUMER_FILE_PATH="xxx"
// export APP_LOG_CONF_FILE="xxx"
var
concurrency
=
flag
.
Int
(
"c"
,
1
,
"concurrency"
)
var
total
=
flag
.
Int
(
"n"
,
1
,
"total requests for all clients"
)
func
main
()
{
flag
.
Parse
()
conc
,
tn
,
err
:=
checkArgs
(
*
concurrency
,
*
total
)
if
err
!=
nil
{
log
.
Printf
(
"err: %v"
,
err
)
return
}
n
:=
conc
m
:=
tn
/
n
log
.
Printf
(
"concurrency: %d
\n
requests per client: %d
\n\n
"
,
n
,
m
)
var
wg
sync
.
WaitGroup
wg
.
Add
(
n
*
m
)
log
.
Printf
(
"sent total %d messages, %d message per client"
,
n
*
m
,
m
)
conMap
,
_
:=
config
.
Load
()
if
conMap
==
nil
{
panic
(
"conMap is nil"
)
}
time
.
Sleep
(
3e9
)
var
startWg
sync
.
WaitGroup
startWg
.
Add
(
n
)
var
trans
uint64
var
transOK
uint64
d
:=
make
([][]
int64
,
n
,
n
)
//it contains warmup time but we can ignore it
totalT
:=
time
.
Now
()
.
UnixNano
()
for
i
:=
0
;
i
<
n
;
i
++
{
dt
:=
make
([]
int64
,
0
,
m
)
d
=
append
(
d
,
dt
)
go
func
(
i
int
)
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
log
.
Print
(
"Recovered in f"
,
r
)
}
}()
//warmup
//for j := 0; j < 5; j++ {
// user := &JsonRPCUser{}
// err := conMap["com.ikurento.user.UserProvider"].GetRPCService().(*UserProvider).GetUser(context.TODO(), []interface{}{"A003"}, user)
// if err != nil {
// fmt.Println(err)
// }
//}
startWg
.
Done
()
startWg
.
Wait
()
for
j
:=
0
;
j
<
m
;
j
++
{
t
:=
time
.
Now
()
.
UnixNano
()
user
:=
&
JsonRPCUser
{}
err
:=
conMap
[
"com.ikurento.user.UserProvider"
]
.
GetRPCService
()
.
(
*
UserProvider
)
.
GetUser
(
context
.
TODO
(),
[]
interface
{}{
"A003"
},
user
)
t
=
time
.
Now
()
.
UnixNano
()
-
t
d
[
i
]
=
append
(
d
[
i
],
t
)
if
err
==
nil
&&
user
.
ID
!=
""
{
atomic
.
AddUint64
(
&
transOK
,
1
)
}
if
err
!=
nil
{
log
.
Print
(
err
.
Error
())
}
atomic
.
AddUint64
(
&
trans
,
1
)
wg
.
Done
()
}
}(
i
)
}
wg
.
Wait
()
totalT
=
time
.
Now
()
.
UnixNano
()
-
totalT
log
.
Printf
(
"took %f ms for %d requests
\n
"
,
float64
(
totalT
)
/
1000000
,
n
*
m
)
totalD
:=
make
([]
int64
,
0
,
n
*
m
)
for
_
,
k
:=
range
d
{
totalD
=
append
(
totalD
,
k
...
)
}
totalD2
:=
make
([]
float64
,
0
,
n
*
m
)
for
_
,
k
:=
range
totalD
{
totalD2
=
append
(
totalD2
,
float64
(
k
))
}
mean
,
_
:=
stats
.
Mean
(
totalD2
)
median
,
_
:=
stats
.
Median
(
totalD2
)
max
,
_
:=
stats
.
Max
(
totalD2
)
min
,
_
:=
stats
.
Min
(
totalD2
)
p99
,
_
:=
stats
.
Percentile
(
totalD2
,
99.9
)
log
.
Printf
(
"sent requests : %d
\n
"
,
n
*
m
)
log
.
Printf
(
"received requests : %d
\n
"
,
atomic
.
LoadUint64
(
&
trans
))
log
.
Printf
(
"received requests_OK : %d
\n
"
,
atomic
.
LoadUint64
(
&
transOK
))
log
.
Printf
(
"throughput (TPS) : %d
\n
"
,
int64
(
n
*
m
)
*
1000000000
/
totalT
)
log
.
Printf
(
"mean: %.f ns, median: %.f ns, max: %.f ns, min: %.f ns, p99.9: %.f ns
\n
"
,
mean
,
median
,
max
,
min
,
p99
)
log
.
Printf
(
"mean: %d ms, median: %d ms, max: %d ms, min: %d ms, p99: %d ms
\n
"
,
int64
(
mean
/
1000000
),
int64
(
median
/
1000000
),
int64
(
max
/
1000000
),
int64
(
min
/
1000000
),
int64
(
p99
/
1000000
))
}
// checkArgs check concurrency and total request count.
func
checkArgs
(
c
,
n
int
)
(
int
,
int
,
error
)
{
if
c
<
1
{
log
.
Printf
(
"c < 1 and reset c = 1"
)
c
=
1
}
if
n
<
1
{
log
.
Printf
(
"n < 1 and reset n = 1"
)
n
=
1
}
if
c
>
n
{
return
c
,
n
,
errors
.
New
(
"c must be set <= n"
)
}
return
c
,
n
,
nil
}
This diff is collapsed.
Click to expand it.
examples/jsonrpc/go-client/benchmark/user.go
deleted
100644 → 0
+
0
−
43
View file @
518e8991
package
main
import
(
"context"
"fmt"
"github.com/dubbo/go-for-apache-dubbo/config"
)
import
(
"github.com/AlexStocks/goext/time"
)
func
init
()
{
config
.
SetConService
(
new
(
UserProvider
))
}
type
JsonRPCUser
struct
{
ID
string
`json:"id"`
Name
string
`json:"name"`
Age
int64
`json:"age"`
Time
int64
`json:"time"`
Sex
string
`json:"sex"`
}
func
(
u
JsonRPCUser
)
String
()
string
{
return
fmt
.
Sprintf
(
"User{ID:%s, Name:%s, Age:%d, Time:%s, Sex:%s}"
,
u
.
ID
,
u
.
Name
,
u
.
Age
,
gxtime
.
YMDPrint
(
int
(
u
.
Time
),
0
),
u
.
Sex
,
)
}
type
UserProvider
struct
{
GetUser
func
(
ctx
context
.
Context
,
req
[]
interface
{},
rsp
*
JsonRPCUser
)
error
GetUser1
func
(
ctx
context
.
Context
,
req
[]
interface
{},
rsp
*
JsonRPCUser
)
error
}
func
(
u
*
UserProvider
)
Service
()
string
{
return
"com.ikurento.user.UserProvider"
}
func
(
u
*
UserProvider
)
Version
()
string
{
return
""
}
This diff is collapsed.
Click to expand it.
Preview
0%
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