mirror of
https://github.com/grassrootseconomics/cic-chain-events.git
synced 2024-11-29 01:56:46 +01:00
Mohammed Sohail
f29e2a9ce7
* move filters to internal folder * rpc block fetcher * add benchmarks: goos: linux goarch: amd64 pkg: github.com/grassrootseconomics/cic-chain-events/pkg/fetch cpu: AMD EPYC Processor Benchmark_RPC Benchmark_RPC/RPC_Block_Fetcher_Benchmark Benchmark_RPC/RPC_Block_Fetcher_Benchmark-4 25 46000646 ns/op 221697 B/op 844 allocs/op Benchmark_GraphQL Benchmark_GraphQL/GraphQL_Block_Fetcher_Benchmark Benchmark_GraphQL/GraphQL_Block_Fetcher_Benchmark-4 56 21219962 ns/op 56686 B/op 94 allocs/op PASS ok github.com/grassrootseconomics/cic-chain-events/pkg/fetch 2.920s
51 lines
918 B
Go
51 lines
918 B
Go
package fetch
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
celo "github.com/grassrootseconomics/cic-celo-sdk"
|
|
)
|
|
|
|
func Benchmark_RPC(b *testing.B) {
|
|
celoProvider, err := celo.NewProvider(celo.ProviderOpts{
|
|
ChainId: celo.MainnetChainId,
|
|
RpcEndpoint: rpcEndpoint,
|
|
})
|
|
|
|
rpc := NewRPCFetcher(RPCOpts{
|
|
RPCProvider: celoProvider,
|
|
})
|
|
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
b.Run("RPC_Block_Fetcher_Benchmark", func(b *testing.B) {
|
|
for n := 0; n < b.N; n++ {
|
|
_, err := rpc.Block(context.Background(), 14974600)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
b.ReportAllocs()
|
|
})
|
|
}
|
|
|
|
func Benchmark_GraphQL(b *testing.B) {
|
|
graphql := NewGraphqlFetcher(GraphqlOpts{
|
|
GraphqlEndpoint: graphqlEndpoint,
|
|
})
|
|
|
|
b.Run("GraphQL_Block_Fetcher_Benchmark", func(b *testing.B) {
|
|
for n := 0; n < b.N; n++ {
|
|
_, err := graphql.Block(context.Background(), 14974600)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
b.ReportAllocs()
|
|
})
|
|
|
|
}
|