-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8652 from influxdata/sgc-literal-cursor
Reduce allocations using nil cursors and literal value cursors
- Loading branch information
Showing
6 changed files
with
77 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package tsm1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/influxdata/influxdb/influxql" | ||
) | ||
|
||
func BenchmarkIntegerIterator_Next(b *testing.B) { | ||
opt := influxql.IteratorOptions{ | ||
Aux: []influxql.VarRef{{Val: "f1"}, {Val: "f1"}, {Val: "f1"}, {Val: "f1"}}, | ||
} | ||
aux := []cursorAt{ | ||
&literalValueCursor{value: "foo bar"}, | ||
&literalValueCursor{value: int64(1e3)}, | ||
&literalValueCursor{value: float64(1e3)}, | ||
&literalValueCursor{value: true}, | ||
} | ||
|
||
cur := newIntegerIterator("m0", influxql.Tags{}, opt, &infiniteIntegerCursor{}, aux, nil, nil) | ||
|
||
b.ResetTimer() | ||
b.ReportAllocs() | ||
for i := 0; i < b.N; i++ { | ||
cur.Next() | ||
} | ||
} | ||
|
||
type infiniteIntegerCursor struct{} | ||
|
||
func (*infiniteIntegerCursor) close() error { | ||
return nil | ||
} | ||
|
||
func (*infiniteIntegerCursor) next() (t int64, v interface{}) { | ||
return 0, 0 | ||
} | ||
|
||
func (*infiniteIntegerCursor) nextInteger() (t int64, v int64) { | ||
return 0, 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters