Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
c5ee6a7b
Commit
c5ee6a7b
authored
Jun 05, 2019
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
ab25c4be
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
294 additions
and
0 deletions
+294
-0
kvm_perf.go
kvm_perf.go
+97
-0
mavl_perf.go
mavl_perf.go
+99
-0
mpt_perf.go
mpt_perf.go
+98
-0
No files found.
kvm_perf.go
0 → 100644
View file @
c5ee6a7b
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
main
import
(
"io/ioutil"
"os"
"time"
"fmt"
"github.com/33cn/chain33/common"
drivers
"github.com/33cn/chain33/system/store"
"github.com/33cn/chain33/types"
kvm
"github.com/33cn/plugin/plugin/store/kvmvcc"
)
const
MaxKeylenth
int
=
64
func
newStoreCfg
(
dir
string
)
*
types
.
Store
{
return
&
types
.
Store
{
Name
:
"kvmvcc_test"
,
Driver
:
"leveldb"
,
DbPath
:
dir
,
DbCache
:
100
}
}
func
GetRandomString
(
length
int
)
string
{
return
common
.
GetRandPrintString
(
20
,
length
)
}
func
main
()
{
dir
,
_
:=
ioutil
.
TempDir
(
""
,
"kvmvcc"
)
//defer os.RemoveAll(dir) // clean up
os
.
RemoveAll
(
dir
)
//删除已存在目录
var
storeCfg
=
newStoreCfg
(
dir
)
store
:=
kvm
.
New
(
storeCfg
,
nil
)
.
(
*
kvm
.
KVMVCCStore
)
var
kv
[]
*
types
.
KeyValue
var
key
string
var
value
string
var
keys
[][]
byte
for
i
:=
0
;
i
<
20
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"vabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
var
hashes
[][]
byte
blocks
:=
5000000
times
:=
1000000
start1
:=
time
.
Now
()
for
i
:=
0
;
i
<
blocks
;
i
++
{
datas
.
Height
=
int64
(
i
)
value
=
fmt
.
Sprintf
(
"vvabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d"
,
i
)
for
j
:=
0
;
j
<
20
;
j
++
{
datas
.
KV
[
j
]
.
Value
=
[]
byte
(
value
)
}
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
if
err
!=
nil
{
fmt
.
Println
(
"MemSet failed"
,
err
)
}
req
:=
&
types
.
ReqHash
{
Hash
:
hash
,
}
_
,
err
=
store
.
Commit
(
req
)
if
err
!=
nil
{
fmt
.
Println
(
"Commit failed"
,
err
)
}
datas
.
StateHash
=
hash
if
i
<
times
{
hashes
=
append
(
hashes
,
hash
)
}
}
end1
:=
time
.
Now
()
start
:=
time
.
Now
()
getData
:=
&
types
.
StoreGet
{
StateHash
:
hashes
[
0
],
Keys
:
keys
}
for
i
:=
0
;
i
<
times
;
i
++
{
getData
.
StateHash
=
hashes
[
i
]
store
.
Get
(
getData
)
}
end
:=
time
.
Now
()
fmt
.
Println
(
"kvmvcc BenchmarkStoreGetKvsFor100million MemSet&Commit cost time is "
,
end1
.
Sub
(
start1
),
"blocks is"
,
blocks
)
fmt
.
Println
(
"kvmvcc BenchmarkStoreGetKvsFor100million Get cost time is"
,
end
.
Sub
(
start
),
"num is "
,
times
,
",blocks is "
,
blocks
)
}
mavl_perf.go
0 → 100644
View file @
c5ee6a7b
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
main
import
(
"github.com/33cn/plugin/plugin/store/mpt"
"io/ioutil"
"os"
"time"
"fmt"
"github.com/33cn/chain33/common"
drivers
"github.com/33cn/chain33/system/store"
"github.com/33cn/chain33/types"
mavl
"github.com/33cn/chain33/system/store/mavl"
)
const
MaxKeylenth
int
=
64
func
newStoreCfg
(
dir
string
)
*
types
.
Store
{
return
&
types
.
Store
{
Name
:
"mavl_test"
,
Driver
:
"leveldb"
,
DbPath
:
dir
,
DbCache
:
100
}
}
func
GetRandomString
(
length
int
)
string
{
return
common
.
GetRandPrintString
(
20
,
length
)
}
func
main
()
{
dir
,
_
:=
ioutil
.
TempDir
(
""
,
"mavl"
)
//defer os.RemoveAll(dir) // clean up
os
.
RemoveAll
(
dir
)
//删除已存在目录
var
storeCfg
=
newStoreCfg
(
dir
)
store
:=
mpt
.
New
(
storeCfg
,
nil
)
.
(
*
mavl
.
Store
)
var
kv
[]
*
types
.
KeyValue
var
key
string
var
value
string
var
keys
[][]
byte
for
i
:=
0
;
i
<
20
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"vabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
var
hashes
[][]
byte
blocks
:=
5000000
times
:=
1000000
start1
:=
time
.
Now
()
for
i
:=
0
;
i
<
blocks
;
i
++
{
datas
.
Height
=
int64
(
i
)
value
=
fmt
.
Sprintf
(
"vvabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d"
,
i
)
for
j
:=
0
;
j
<
20
;
j
++
{
datas
.
KV
[
j
]
.
Value
=
[]
byte
(
value
)
}
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
if
err
!=
nil
{
fmt
.
Println
(
"MemSet failed"
,
err
)
}
req
:=
&
types
.
ReqHash
{
Hash
:
hash
,
}
_
,
err
=
store
.
Commit
(
req
)
if
err
!=
nil
{
fmt
.
Println
(
"Commit failed"
,
err
)
}
datas
.
StateHash
=
hash
if
i
<
times
{
hashes
=
append
(
hashes
,
hash
)
}
fmt
.
Println
(
"Block number:"
,
i
)
}
end1
:=
time
.
Now
()
start
:=
time
.
Now
()
getData
:=
&
types
.
StoreGet
{
StateHash
:
hashes
[
0
],
Keys
:
keys
}
for
i
:=
0
;
i
<
times
;
i
++
{
getData
.
StateHash
=
hashes
[
i
]
store
.
Get
(
getData
)
}
end
:=
time
.
Now
()
fmt
.
Println
(
"mavl BenchmarkStoreGetKvsFor100million MemSet&Commit cost time is "
,
end1
.
Sub
(
start1
),
"blocks is"
,
blocks
)
fmt
.
Println
(
"mavl BenchmarkStoreGetKvsFor100million Get cost time is"
,
end
.
Sub
(
start
),
"num is "
,
times
,
",blocks is "
,
blocks
)
}
mpt_perf.go
0 → 100644
View file @
c5ee6a7b
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
main
import
(
"io/ioutil"
"os"
"time"
"fmt"
"github.com/33cn/chain33/common"
drivers
"github.com/33cn/chain33/system/store"
"github.com/33cn/chain33/types"
mpt
"github.com/33cn/plugin/plugin/store/mpt"
)
const
MaxKeylenth
int
=
64
func
newStoreCfg
(
dir
string
)
*
types
.
Store
{
return
&
types
.
Store
{
Name
:
"mpt_test"
,
Driver
:
"leveldb"
,
DbPath
:
dir
,
DbCache
:
100
}
}
func
GetRandomString
(
length
int
)
string
{
return
common
.
GetRandPrintString
(
20
,
length
)
}
func
main
()
{
dir
,
_
:=
ioutil
.
TempDir
(
""
,
"mpt"
)
//defer os.RemoveAll(dir) // clean up
os
.
RemoveAll
(
dir
)
//删除已存在目录
var
storeCfg
=
newStoreCfg
(
dir
)
store
:=
mpt
.
New
(
storeCfg
,
nil
)
.
(
*
mpt
.
Store
)
var
kv
[]
*
types
.
KeyValue
var
key
string
var
value
string
var
keys
[][]
byte
for
i
:=
0
;
i
<
20
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"vabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
Height
:
0
}
var
hashes
[][]
byte
blocks
:=
5000000
times
:=
1000000
start1
:=
time
.
Now
()
for
i
:=
0
;
i
<
blocks
;
i
++
{
datas
.
Height
=
int64
(
i
)
value
=
fmt
.
Sprintf
(
"vvabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst%d"
,
i
)
for
j
:=
0
;
j
<
20
;
j
++
{
datas
.
KV
[
j
]
.
Value
=
[]
byte
(
value
)
}
hash
,
err
:=
store
.
MemSet
(
datas
,
true
)
if
err
!=
nil
{
fmt
.
Println
(
"MemSet failed"
,
err
)
}
req
:=
&
types
.
ReqHash
{
Hash
:
hash
,
}
_
,
err
=
store
.
Commit
(
req
)
if
err
!=
nil
{
fmt
.
Println
(
"Commit failed"
,
err
)
}
datas
.
StateHash
=
hash
if
i
<
times
{
hashes
=
append
(
hashes
,
hash
)
}
fmt
.
Println
(
"Block number:"
,
i
)
}
end1
:=
time
.
Now
()
start
:=
time
.
Now
()
getData
:=
&
types
.
StoreGet
{
StateHash
:
hashes
[
0
],
Keys
:
keys
}
for
i
:=
0
;
i
<
times
;
i
++
{
getData
.
StateHash
=
hashes
[
i
]
store
.
Get
(
getData
)
}
end
:=
time
.
Now
()
fmt
.
Println
(
"mpt BenchmarkStoreGetKvsFor100million MemSet&Commit cost time is "
,
end1
.
Sub
(
start1
),
"blocks is"
,
blocks
)
fmt
.
Println
(
"mpt BenchmarkStoreGetKvsFor100million Get cost time is"
,
end
.
Sub
(
start
),
"num is "
,
times
,
",blocks is "
,
blocks
)
}
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