re-arrange benchmark file

This commit is contained in:
William Banfield
2021-07-21 09:22:13 -04:00
parent b6b286813a
commit c3c4274d67
+39 -39
View File
@@ -26,45 +26,6 @@ var (
genesisBlock, _ = benchmarkFullNode.LightBlock(context.Background(), 1)
)
type providerBenchmarkImpl struct {
chainID string
currentHeight int64
blocks map[int64]*types.LightBlock
}
func newProviderBenchmarkImpl(chainID string, headers map[int64]*types.SignedHeader,
vals map[int64]*types.ValidatorSet) provider.Provider {
impl := providerBenchmarkImpl{
chainID: chainID,
blocks: make(map[int64]*types.LightBlock, len(headers)),
}
for height, header := range headers {
if height > impl.currentHeight {
impl.currentHeight = height
}
impl.blocks[height] = &types.LightBlock{
SignedHeader: header,
ValidatorSet: vals[height],
}
}
return &impl
}
func (impl *providerBenchmarkImpl) LightBlock(ctx context.Context, height int64) (*types.LightBlock, error) {
if height == 0 {
return impl.blocks[impl.currentHeight], nil
}
lb, ok := impl.blocks[height]
if !ok {
return nil, provider.ErrLightBlockNotFound
}
return lb, nil
}
func (impl *providerBenchmarkImpl) ReportEvidence(_ context.Context, _ types.Evidence) error {
panic("not implemented")
}
func BenchmarkSequence(b *testing.B) {
c, err := light.NewClient(
context.Background(),
@@ -147,3 +108,42 @@ func BenchmarkBackwards(b *testing.B) {
}
}
}
type providerBenchmarkImpl struct {
chainID string
currentHeight int64
blocks map[int64]*types.LightBlock
}
func newProviderBenchmarkImpl(chainID string, headers map[int64]*types.SignedHeader,
vals map[int64]*types.ValidatorSet) provider.Provider {
impl := providerBenchmarkImpl{
chainID: chainID,
blocks: make(map[int64]*types.LightBlock, len(headers)),
}
for height, header := range headers {
if height > impl.currentHeight {
impl.currentHeight = height
}
impl.blocks[height] = &types.LightBlock{
SignedHeader: header,
ValidatorSet: vals[height],
}
}
return &impl
}
func (impl *providerBenchmarkImpl) LightBlock(ctx context.Context, height int64) (*types.LightBlock, error) {
if height == 0 {
return impl.blocks[impl.currentHeight], nil
}
lb, ok := impl.blocks[height]
if !ok {
return nil, provider.ErrLightBlockNotFound
}
return lb, nil
}
func (impl *providerBenchmarkImpl) ReportEvidence(_ context.Context, _ types.Evidence) error {
panic("not implemented")
}