mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add benchmark tests for JSON and GOB in sessions_bench_test.go
This commit is contained in:
committed by
Dan Christian Bogos
parent
648911d82b
commit
5cb5fb5661
@@ -107,7 +107,8 @@ func testDspApierGetAttributes(t *testing.T) {
|
||||
if err := dispEngine.RCP.Call("ApierV1.GetAttributeProfile",
|
||||
utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_Dispatcher"},
|
||||
ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("apier12345")}}, &reply); err != nil {
|
||||
ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("apier12345")},
|
||||
}, &reply); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
reply.Compile()
|
||||
@@ -119,12 +120,11 @@ func testDspApierGetAttributes(t *testing.T) {
|
||||
|
||||
func testDspApierUnkownAPiKey(t *testing.T) {
|
||||
var reply *engine.AttributeProfile
|
||||
|
||||
if err := dispEngine.RCP.Call("ApierV1.GetAttributeProfile",
|
||||
utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_Dispatcher"},
|
||||
ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("RandomApiKey")}}, &reply); err == nil || err.Error() != utils.ErrUnknownApiKey.Error() {
|
||||
ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("RandomApiKey")},
|
||||
}, &reply); err == nil || err.Error() != utils.ErrUnknownApiKey.Error() {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ var (
|
||||
func startRPC() {
|
||||
var err error
|
||||
sBenchCfg, err = config.NewCGRConfigFromPath(
|
||||
path.Join(config.CgrConfig().DataFolderPath, "conf", "samples", "tutmysql"))
|
||||
path.Join(config.CgrConfig().DataFolderPath, "conf", "samples", "tutmongo"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -183,6 +183,50 @@ func BenchmarkSendInitSession(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkEncodingJSON(b *testing.B) {
|
||||
maxCps = make(chan struct{}, *cps)
|
||||
for i := 0; i < *cps; i++ { // init CPS limitation
|
||||
maxCps <- struct{}{}
|
||||
}
|
||||
var err error
|
||||
sBenchCfg, err = config.NewCGRConfigFromPath(
|
||||
path.Join(config.CgrConfig().DataFolderPath, "conf", "samples", "tutmongo"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if sBenchRPC, err = jsonrpc.Dial("tcp", sBenchCfg.ListenCfg().RPCJSONListen); err != nil {
|
||||
log.Fatalf("Error at dialing rcp client:%v\n", err)
|
||||
}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
initSession(i)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func BenchmarkEncodingGOB(b *testing.B) {
|
||||
maxCps = make(chan struct{}, *cps)
|
||||
for i := 0; i < *cps; i++ { // init CPS limitation
|
||||
maxCps <- struct{}{}
|
||||
}
|
||||
var err error
|
||||
sBenchCfg, err = config.NewCGRConfigFromPath(
|
||||
path.Join(config.CgrConfig().DataFolderPath, "conf", "samples", "tutmongo"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if sBenchRPC, err = rpc.Dial("tcp", sBenchCfg.ListenCfg().RPCGOBListen); err != nil {
|
||||
log.Fatalf("Error at dialing rcp client:%v\n", err)
|
||||
}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
initSession(i)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func benchmarkSendInitSessionx10(b *testing.B) {
|
||||
connOnce.Do(func() {
|
||||
startRPC()
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package utils
|
||||
@@ -497,7 +497,11 @@ func (s *Server) ServeHTTPTLS(addr, serverCrt, serverKey, caCert string, serverP
|
||||
s.Unlock()
|
||||
Logger.Info("<HTTPTLS> enabling handler for WebSocket connections")
|
||||
wsHandler := websocket.Handler(func(ws *websocket.Conn) {
|
||||
jsonrpc.ServeConn(ws)
|
||||
if s.isDispatched {
|
||||
rpc.ServeCodec(NewCustomJSONServerCodec(ws))
|
||||
} else {
|
||||
jsonrpc.ServeConn(ws)
|
||||
}
|
||||
})
|
||||
if useBasicAuth {
|
||||
s.httpsMux.HandleFunc(wsRPCURL, use(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user