394 lines
11 KiB
Plaintext
394 lines
11 KiB
Plaintext
type Lookup {
|
|
values: Map<Int, Int>
|
|
index: Int
|
|
total: Int
|
|
}
|
|
|
|
selected(value: Int) (answer: Int) { answer = value }
|
|
selected(value: null) (answer: Int) { answer = 0 }
|
|
|
|
lookup(value: Int, state: Lookup) (next: Lookup) {
|
|
found = selected(get(state.values, state.index))
|
|
next = Lookup { values = state.values
|
|
index = state.index + 1
|
|
total = state.total + found }
|
|
}
|
|
|
|
mapLookup(ticks: Text) (sample: Sample) {
|
|
input = dever.bytes.fromText(ticks)
|
|
values = reduce(putValue, input, {})
|
|
initial = Lookup { values = values
|
|
index = 0
|
|
total = 0 }
|
|
begin = dever.time.monotonicNanos()
|
|
final = reduce(lookup, input, initial)
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = final.total }
|
|
}
|
|
|
|
continuousMapLookup(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(mapLookup, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
type TextLookup {
|
|
values: Map<Text, Int>
|
|
total: Int
|
|
}
|
|
|
|
type TextPair {
|
|
left: Text
|
|
right: Text
|
|
}
|
|
|
|
textEntry(entry: MapEntry<Int, Int>, state: Map<Text, Int>) (next: Map<Text, Int>) {
|
|
next = put(state, "lookup-key-" + int.toText(entry.key), entry.value)
|
|
}
|
|
|
|
textKey(entry: MapEntry<Text, Int>) (key: Text) { key = entry.key }
|
|
|
|
textLookup(key: Text, state: TextLookup) (next: TextLookup) {
|
|
found = selected(get(state.values, key))
|
|
next = TextLookup { values = state.values
|
|
total = state.total + found }
|
|
}
|
|
|
|
mapTextLookup(ticks: Text) (sample: Sample) {
|
|
input = dever.bytes.fromText(ticks)
|
|
values = reduce(textEntry, entries(reduce(putValue, input, {})), {})
|
|
keys = each(textKey, entries(values))
|
|
initial = TextLookup { values = values
|
|
total = 0 }
|
|
begin = dever.time.monotonicNanos()
|
|
final = reduce(textLookup, keys, initial)
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = final.total + length(keys) - length(input) }
|
|
}
|
|
|
|
continuousMapTextLookup(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(mapTextLookup, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
textPair(value: Int) (pair: TextPair) {
|
|
left = "compare-value-" + int.toText(value)
|
|
pair = TextPair { left = left
|
|
right = text.lower(text.upper(left)) }
|
|
}
|
|
|
|
matchedValue(matched: true) (value: Int) { value = 120 }
|
|
matchedValue(matched: false) (value: Int) { value = 0 }
|
|
|
|
equalTextPair(row: TextPair, total: Int) (next: Int) {
|
|
next = total + matchedValue(row.left == row.right)
|
|
}
|
|
|
|
containsTextPair(row: TextPair, total: Int) (next: Int) {
|
|
next = total + matchedValue(text.contains(row.left, row.right))
|
|
}
|
|
|
|
textEqual(ticks: Text) (sample: Sample) {
|
|
input = dever.bytes.fromText(ticks)
|
|
rows = each(textPair, input)
|
|
begin = dever.time.monotonicNanos()
|
|
total = reduce(equalTextPair, rows, 0)
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = total + length(rows) - length(input) }
|
|
}
|
|
|
|
continuousTextEqual(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(textEqual, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
textContains(ticks: Text) (sample: Sample) {
|
|
input = dever.bytes.fromText(ticks)
|
|
rows = each(textPair, input)
|
|
begin = dever.time.monotonicNanos()
|
|
total = reduce(containsTextPair, rows, 0)
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = total + length(rows) - length(input) }
|
|
}
|
|
|
|
continuousTextContains(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(textContains, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
type Sample {
|
|
elapsed_ns: Int
|
|
checksum: Int
|
|
}
|
|
|
|
type FloatSample {
|
|
elapsed_ns: Int
|
|
checksum: Float
|
|
}
|
|
|
|
addFloat(value: Int, state: Float) (next: Float) {
|
|
next = state + float.fromInt(value)
|
|
}
|
|
|
|
float(ticks: Text) (sample: FloatSample) {
|
|
bytes = dever.bytes.fromText(ticks)
|
|
zero = float.fromInt(0)
|
|
begin = dever.time.monotonicNanos()
|
|
total = reduce(addFloat, bytes, zero)
|
|
end = dever.time.monotonicNanos()
|
|
sample = FloatSample { elapsed_ns = end - begin
|
|
checksum = total }
|
|
}
|
|
|
|
joinBytes(value: Bytes, state: Bytes) (next: Bytes) {
|
|
next = dever.bytes.concat(state, value)
|
|
}
|
|
|
|
bytesConcat(ticks: Text) (sample: Sample) {
|
|
chunks = each(dever.bytes.fromText, text.split(ticks, ""))
|
|
empty = dever.bytes.fromText("")
|
|
begin = dever.time.monotonicNanos()
|
|
output = reduce(joinBytes, chunks, empty)
|
|
end = dever.time.monotonicNanos()
|
|
total = reduce(add, output, 0)
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = total }
|
|
}
|
|
|
|
joinText(value: Text, state: Text) (next: Text) {
|
|
next = state + value
|
|
}
|
|
|
|
textConcat(ticks: Text) (sample: Sample) {
|
|
chunks = text.split(ticks, ",")
|
|
begin = dever.time.monotonicNanos()
|
|
output = reduce(joinText, chunks, "")
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample {
|
|
elapsed_ns = end - begin
|
|
checksum = reduce(add, dever.bytes.fromText(output), 0)
|
|
}
|
|
}
|
|
|
|
add(value: Int, state: Int) (next: Int) {
|
|
next = state + value
|
|
}
|
|
|
|
appendValue(value: Int, state: List<Int>) (next: List<Int>) {
|
|
next = append(state, value)
|
|
}
|
|
|
|
putValue(value: Int, state: Map<Int, Int>) (next: Map<Int, Int>) {
|
|
key = length(state)
|
|
next = put(state, key, value)
|
|
}
|
|
|
|
mapped(entry: MapEntry<Int, Int>) (value: Int) {
|
|
value = entry.value
|
|
}
|
|
|
|
integer(ticks: Text) (sample: Sample) {
|
|
input = dever.bytes.fromText(ticks)
|
|
begin = dever.time.monotonicNanos()
|
|
value = reduce(add, input, 0)
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample {
|
|
elapsed_ns = end - begin
|
|
checksum = value
|
|
}
|
|
}
|
|
|
|
list(ticks: Text) (sample: Sample) {
|
|
input = dever.bytes.fromText(ticks)
|
|
begin = dever.time.monotonicNanos()
|
|
value = reduce(appendValue, input, [])
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample {
|
|
elapsed_ns = end - begin
|
|
checksum = sum(value)
|
|
}
|
|
}
|
|
|
|
map(ticks: Text) (sample: Sample) {
|
|
input = dever.bytes.fromText(ticks)
|
|
begin = dever.time.monotonicNanos()
|
|
value = reduce(putValue, input, {})
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample {
|
|
elapsed_ns = end - begin
|
|
checksum = sum(each(mapped, entries(value)))
|
|
}
|
|
}
|
|
|
|
listRead(ticks: Text) (sample: Sample) {
|
|
values = reduce(appendValue, dever.bytes.fromText(ticks), [])
|
|
begin = dever.time.monotonicNanos()
|
|
total = sum(values)
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = total }
|
|
}
|
|
|
|
mapRead(ticks: Text) (sample: Sample) {
|
|
values = reduce(putValue, dever.bytes.fromText(ticks), {})
|
|
begin = dever.time.monotonicNanos()
|
|
total = sum(mapped, entries(values))
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = total }
|
|
}
|
|
|
|
type Record {
|
|
first: Int
|
|
second: Int
|
|
third: Int
|
|
}
|
|
|
|
appendRecord(value: Int, state: List<Record>) (next: List<Record>) {
|
|
next = append(state, Record { first = value
|
|
second = 0
|
|
third = 0 })
|
|
}
|
|
|
|
recordValue(row: Record) (value: Int) {
|
|
value = row.first + row.second + row.third
|
|
}
|
|
|
|
listRecord(ticks: Text) (sample: Sample) {
|
|
input = dever.bytes.fromText(ticks)
|
|
begin = dever.time.monotonicNanos()
|
|
values = reduce(appendRecord, input, [])
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = sum(recordValue, values) }
|
|
}
|
|
|
|
listRecordRead(ticks: Text) (sample: Sample) {
|
|
values = reduce(appendRecord, dever.bytes.fromText(ticks), [])
|
|
begin = dever.time.monotonicNanos()
|
|
total = sum(recordValue, values)
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = total }
|
|
}
|
|
|
|
continuousInteger(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(integer, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
continuousFloat(ticks: Text) (samples: List<FloatSample>) {
|
|
samples = each(float, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
continuousList(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(list, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
continuousMap(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(map, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
continuousListRead(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(listRead, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
continuousMapRead(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(mapRead, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
continuousListRecord(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(listRecord, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
continuousListRecordRead(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(listRecordRead, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
continuousTextConcat(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(textConcat, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
continuousBytesConcat(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(bytesConcat, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
type OwnedRecord {
|
|
name: Text
|
|
tags: List<Text>
|
|
count: Int
|
|
}
|
|
|
|
ownedRecord(value: Int) (row: OwnedRecord) {
|
|
name = "row-value-" + int.toText(value)
|
|
row = OwnedRecord { name = name
|
|
tags = [name]
|
|
count = value - length(name) - 1 }
|
|
}
|
|
|
|
inspectOwned(row: OwnedRecord) (value: Int) {
|
|
value = row.count + length(row.name) + length(row.tags)
|
|
}
|
|
|
|
forwardOwned(row: OwnedRecord) (value: Int) {
|
|
value = inspectOwned(row)
|
|
}
|
|
|
|
callRead(ticks: Text) (sample: Sample) {
|
|
rows = each(ownedRecord, dever.bytes.fromText(ticks))
|
|
begin = dever.time.monotonicNanos()
|
|
total = sum(forwardOwned, rows)
|
|
end = dever.time.monotonicNanos()
|
|
preserved = length(rows)
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = total + preserved - length(rows) }
|
|
}
|
|
|
|
continuousCallRead(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(callRead, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
type Accumulator {
|
|
values: List<Int>
|
|
count: Int
|
|
}
|
|
|
|
appendField(value: Int, state: Accumulator) (next: Accumulator) {
|
|
values = append(state.values, value)
|
|
next = Accumulator { values = values
|
|
count = state.count + 1 }
|
|
}
|
|
|
|
recordUpdate(ticks: Text) (sample: Sample) {
|
|
input = dever.bytes.fromText(ticks)
|
|
begin = dever.time.monotonicNanos()
|
|
state = reduce(appendField, input, Accumulator { values = []
|
|
count = 0 })
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = sum(state.values) + state.count - length(state.values) }
|
|
}
|
|
|
|
continuousRecordUpdate(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(recordUpdate, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|
|
|
|
appendInspected(value: Int, state: Accumulator) (next: Accumulator) {
|
|
count = length(state.values) + 1
|
|
values = append(state.values, value)
|
|
next = Accumulator { values = values
|
|
count = count }
|
|
}
|
|
|
|
recordInspect(ticks: Text) (sample: Sample) {
|
|
input = dever.bytes.fromText(ticks)
|
|
begin = dever.time.monotonicNanos()
|
|
state = reduce(appendInspected, input, Accumulator { values = []
|
|
count = 0 })
|
|
end = dever.time.monotonicNanos()
|
|
sample = Sample { elapsed_ns = end - begin
|
|
checksum = sum(state.values) + state.count - length(state.values) }
|
|
}
|
|
|
|
continuousRecordInspect(ticks: Text) (samples: List<Sample>) {
|
|
samples = each(recordInspect, [ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks, ticks])
|
|
}
|