feat: publish Dever core with project scaffolding and versioned AI skills
This commit is contained in:
1 parent
70fa73cdc2
commit
ac458ffa7f
960 files changed
+221319
-1163
No files matched your search
@@ -0,0 +1,95 @@
|
||||
type Buffer {
|
||||
text: Text
|
||||
count: Int
|
||||
}
|
||||
|
||||
type Index {
|
||||
values: Map<Int, Int>
|
||||
next: Int
|
||||
}
|
||||
|
||||
double(value: Int, text: Text) (next: Text) {
|
||||
next = text + text
|
||||
}
|
||||
|
||||
grow(value: Int, state: Buffer) (next: Buffer) {
|
||||
next = state
|
||||
next.text = state.text + "a"
|
||||
next.count = state.count + 1
|
||||
}
|
||||
|
||||
insert(value: Int, state: Index) (next: Index) {
|
||||
next = state
|
||||
next.values = put(state.values, state.next, value)
|
||||
next.next = state.next + 1
|
||||
}
|
||||
|
||||
word(value: Int) (result: Text) {
|
||||
result = "abcdefgh你好"
|
||||
}
|
||||
|
||||
copy(value: Text) (result: Text) {
|
||||
result = value
|
||||
}
|
||||
|
||||
clock(value: dever.time.ClockResult.Read(nanos)) (result: Int) recover("benchmark clock failures are reported") {
|
||||
result = nanos
|
||||
}
|
||||
|
||||
clock(value: dever.time.ClockResult.Failed(message)) (result: Int) recover("benchmark clock failures are reported") {
|
||||
dever.io.println("FAILED:" + message)
|
||||
result = 0
|
||||
}
|
||||
|
||||
json(value: dever.json.value.ParseResult.Parsed(document)) (result: Int) recover("benchmark parse failures are reported") {
|
||||
result = length(document.nodes)
|
||||
}
|
||||
|
||||
json(value: dever.json.value.ParseResult.Failed(position, message)) (result: Int) recover("benchmark parse failures are reported") {
|
||||
dever.io.println("FAILED:" + message)
|
||||
result = 0
|
||||
}
|
||||
|
||||
sample(index: Int, bytes: Bytes) () {
|
||||
start = clock(result(dever.time.monotonic_nanos()))
|
||||
buffer = reduce(
|
||||
grow,
|
||||
bytes,
|
||||
Buffer {
|
||||
text = ""
|
||||
count = 0
|
||||
}
|
||||
)
|
||||
text_end = clock(result(dever.time.monotonic_nanos()))
|
||||
mapped = each(copy, each(word, bytes))
|
||||
list_end = clock(result(dever.time.monotonic_nanos()))
|
||||
document = json(result(dever.json.parse("\"" + buffer.text + "\"")))
|
||||
json_end = clock(result(dever.time.monotonic_nanos()))
|
||||
dever.io.println(
|
||||
"text|" + int.to_text(buffer.count) + "|" + int.to_text(text_end - start)
|
||||
)
|
||||
dever.io.println(
|
||||
"list|" + int.to_text(length(mapped)) + "|" + int.to_text(list_end - text_end)
|
||||
)
|
||||
dever.io.println(
|
||||
"json|" + int.to_text(document) + "|" + int.to_text(json_end - list_end)
|
||||
)
|
||||
}
|
||||
|
||||
run() () {
|
||||
text = reduce(double, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], "a")
|
||||
each(sample, [0, 1, 2, 3, 4, 5], dever.bytes.from_text(text))
|
||||
start = clock(result(dever.time.monotonic_nanos()))
|
||||
index = reduce(
|
||||
insert,
|
||||
dever.bytes.from_text(text),
|
||||
Index {
|
||||
values = {}
|
||||
next = 0
|
||||
}
|
||||
)
|
||||
end = clock(result(dever.time.monotonic_nanos()))
|
||||
dever.io.println(
|
||||
"map|" + int.to_text(length(index.values)) + "|" + int.to_text(end - start)
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
main() () {
|
||||
benchmark.allocation.run()
|
||||
}
|
||||
Reference in new issue
Block a user