mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-24 18:21:38 +00:00
.
This commit is contained in:
@ -108,38 +108,6 @@ func BenchmarkTestGob(b *testing.B) {
|
||||
func BenchmarkTestMsgPack(b *testing.B) {
|
||||
b.StopTimer()
|
||||
|
||||
var mh codec.MsgpackHandle
|
||||
handle := &mh
|
||||
|
||||
h := &Header{
|
||||
Name: "Header",
|
||||
Height: 123,
|
||||
Fees: 123,
|
||||
Time: 123,
|
||||
PrevHash: []byte("prevhash"),
|
||||
ValidationHash: []byte("validationhash"),
|
||||
DataHash: []byte("datahash"),
|
||||
}
|
||||
h2 := &Header{}
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
enc := codec.NewEncoder(buf, handle)
|
||||
dec := codec.NewDecoder(buf, handle)
|
||||
|
||||
b.StartTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf.Reset()
|
||||
enc.Encode(h)
|
||||
dec.Decode(h2)
|
||||
if h2.Name != "Header" {
|
||||
b.Fatalf("wrong name")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkTestMsgPack2(b *testing.B) {
|
||||
b.StopTimer()
|
||||
|
||||
h := &Header{
|
||||
Name: "Header",
|
||||
Height: 123,
|
||||
@ -165,3 +133,34 @@ func BenchmarkTestMsgPack2(b *testing.B) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkTestMsgPack2(b *testing.B) {
|
||||
b.StopTimer()
|
||||
|
||||
h := &Header{
|
||||
Name: "Header",
|
||||
Height: 123,
|
||||
Fees: 123,
|
||||
Time: 123,
|
||||
PrevHash: []byte("prevhash"),
|
||||
ValidationHash: []byte("validationhash"),
|
||||
DataHash: []byte("datahash"),
|
||||
}
|
||||
h2 := &Header{}
|
||||
var mh codec.MsgpackHandle
|
||||
handle := &mh
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
enc := codec.NewEncoder(buf, handle)
|
||||
dec := codec.NewDecoder(buf, handle)
|
||||
|
||||
b.StartTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf.Reset()
|
||||
enc.Encode(h)
|
||||
dec.Decode(h2)
|
||||
if h2.Name != "Header" {
|
||||
b.Fatalf("wrong name")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
main.go
20
main.go
@ -1,10 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
@ -64,7 +62,7 @@ func main() {
|
||||
go p2p.PexHandler(sw, book)
|
||||
|
||||
// Sleep forever
|
||||
go _trapSignal()
|
||||
trapSignal()
|
||||
select {}
|
||||
}
|
||||
|
||||
@ -73,26 +71,12 @@ func initPeer(peer *p2p.Peer) {
|
||||
}
|
||||
|
||||
func trapSignal() {
|
||||
ch := make(chan os.Signal)
|
||||
signal.Notify(ch, syscall.SIGINT)
|
||||
sig := <-ch
|
||||
fmt.Println("???", sig)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func _trapSignal() {
|
||||
// capture ctrl+c and stop CPU profiler
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
//signal.Notify(c, syscall.SIGINT)
|
||||
go func() {
|
||||
fmt.Println("inside")
|
||||
for sig := range c {
|
||||
fmt.Println("signal!>>", sig)
|
||||
log.Infof("captured %v, stopping profiler and exiting..", sig)
|
||||
log.Infof("captured %v, exiting..", sig)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("inside done")
|
||||
}()
|
||||
fmt.Println("ok")
|
||||
}
|
||||
|
Reference in New Issue
Block a user