Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cue/stats: add metric for builtin calls #2587

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions cmd/cue/cmd/testdata/script/stats.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ contents overwritten
"Unifications": 4,
"Disjuncts": 6,
"Conjuncts": 8,
"Builtins": 0,
"Freed": 6,
"Reused": 2,
"Allocs": 4,
Expand All @@ -54,6 +55,7 @@ CUE: {
Unifications: 4
Disjuncts: 6
Conjuncts: 8
Builtins: 0
Freed: 6
Reused: 2
Allocs: 4
Expand All @@ -68,6 +70,7 @@ CUE:
Unifications: 4
Disjuncts: 6
Conjuncts: 8
Builtins: 0
Freed: 6
Reused: 2
Allocs: 4
Expand All @@ -81,6 +84,7 @@ Go:
"Unifications": 4,
"Disjuncts": 6,
"Conjuncts": 8,
"Builtins": 0,
"Freed": 6,
"Reused": 2,
"Allocs": 4,
Expand Down
9 changes: 8 additions & 1 deletion cue/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type Counts struct {
// algorithmic behavior.
Conjuncts int64

// Builtins indicates the number of total builtin functions executed (like
// `strings.ToLower`).
Builtins int64

// Buffer counters
//
// Each unification and disjunct operation is associated with an object
Expand All @@ -71,6 +75,7 @@ func (c *Counts) Add(other Counts) {
c.Unifications += other.Unifications
c.Conjuncts += other.Conjuncts
c.Disjuncts += other.Disjuncts
c.Builtins += other.Builtins

c.Freed += other.Freed
c.Retained += other.Retained
Expand All @@ -82,6 +87,7 @@ func (c Counts) Since(start Counts) Counts {
c.Unifications -= start.Unifications
c.Conjuncts -= start.Conjuncts
c.Disjuncts -= start.Disjuncts
c.Builtins -= start.Builtins

c.Freed -= start.Freed
c.Retained -= start.Retained
Expand Down Expand Up @@ -110,7 +116,8 @@ Retain: {{.Retained}}

Unifications: {{.Unifications}}
Conjuncts: {{.Conjuncts}}
Disjuncts: {{.Disjuncts}}`))
Disjuncts: {{.Disjuncts}}
Builtins: {{.Builtins}}`))

func (s Counts) String() string {
buf := &strings.Builder{}
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/000_errors.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Retain: 0
Unifications: 10
Conjuncts: 14
Disjuncts: 10
Builtins: 0
-- out/eval --
Errors:
explicit error (_|_ literal) in source:
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/001_regexp.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Retain: 0
Unifications: 16
Conjuncts: 25
Disjuncts: 16
Builtins: 0
-- out/eval --
Errors:
e3: conflicting values !="a" and <5 (mismatched types string and number):
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/002_arithmetic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Retain: 0
Unifications: 24
Conjuncts: 26
Disjuncts: 24
Builtins: 0
-- out/eval --
Errors:
divZero: failed arithmetic: division by zero:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Retain: 0
Unifications: 25
Conjuncts: 25
Disjuncts: 25
Builtins: 0
-- out/eval --
Errors:
qe1: invalid operands 2.0 and 1 to 'quo' (type float and int):
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/004_booleans.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Retain: 0
Unifications: 4
Conjuncts: 7
Disjuncts: 4
Builtins: 0
-- out/eval --
Errors:
e: conflicting values false and true:
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/005_boolean_arithmetic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Retain: 0
Unifications: 7
Conjuncts: 9
Disjuncts: 7
Builtins: 0
-- out/eval --
Errors:
f: conflicting values false and true:
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/006_basic_type.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Retain: 0
Unifications: 7
Conjuncts: 13
Disjuncts: 7
Builtins: 0
-- out/eval --
Errors:
d: conflicting values int and float (mismatched types int and float):
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/007_strings_and_bytes.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Retain: 0
Unifications: 9
Conjuncts: 9
Disjuncts: 9
Builtins: 0
-- out/eval --
Errors:
e0: invalid operands "a" and '' to '+' (type string and bytes):
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/008_escaping.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Retain: 0
Unifications: 3
Conjuncts: 4
Disjuncts: 3
Builtins: 0
-- out/eval --
(struct){
a: (string){ "foo\nbar" }
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/009_reference.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Retain: 1
Unifications: 11
Conjuncts: 13
Disjuncts: 11
Builtins: 0
-- out/eval --
(struct){
a: (int){ 2 }
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/010_lists.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Retain: 4
Unifications: 27
Conjuncts: 46
Disjuncts: 26
Builtins: 0
-- out/eval --
Errors:
e: conflicting values 4 and [] (mismatched types int and list):
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/011_list_arithmetic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Retain: 7
Unifications: 38
Conjuncts: 77
Disjuncts: 38
Builtins: 0
-- out/eval --
Errors:
e: cannot convert negative number to uint64:
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/012_selecting.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Retain: 17
Unifications: 27
Conjuncts: 35
Disjuncts: 25
Builtins: 0
-- out/eval --
Errors:
e: invalid struct selector 4 (type int):
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/013_obj_unify.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Retain: 0
Unifications: 15
Conjuncts: 32
Disjuncts: 15
Builtins: 0
-- out/eval --
Errors:
e: conflicting values 1 and {a:3} (mismatched types int and struct):
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/014_disjunctions.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Retain: 1
Unifications: 18
Conjuncts: 150
Disjuncts: 135
Builtins: 0
-- out/eval --
(struct){
o1: (int){ |((int){ 1 }, (int){ 2 }, (int){ 3 }) }
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/015_types.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Retain: 0
Unifications: 10
Conjuncts: 14
Disjuncts: 10
Builtins: 0
-- out/eval --
Errors:
b: invalid operand int ('!' requires concrete value):
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/016_comparison.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Retain: 0
Unifications: 9
Conjuncts: 10
Disjuncts: 9
Builtins: 0
-- out/eval --
Errors:
err: invalid operands 2 and "s" to '==' (type int and string):
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/017_null.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Retain: 0
Unifications: 8
Conjuncts: 9
Disjuncts: 8
Builtins: 0
-- out/eval --
Errors:
call: cannot call non-function null (type null):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Retain: 11
Unifications: 6
Conjuncts: 26
Disjuncts: 7
Builtins: 0
-- out/eval --
(struct){
a: (_|_){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Retain: 4
Unifications: 18
Conjuncts: 36
Disjuncts: 21
Builtins: 0
-- out/eval --
(struct){
a: (int){ 100 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Retain: 3
Unifications: 6
Conjuncts: 6
Disjuncts: 8
Builtins: 0
-- out/eval --
(struct){
x: (int){ 200 }
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/basicrewrite/aliases/aliases.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Retain: 3
Unifications: 9
Conjuncts: 14
Disjuncts: 10
Builtins: 0
-- out/eval --
(struct){
t0: (struct){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/chain.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -2025,6 +2025,7 @@ Retain: 0
Unifications: 1001
Conjuncts: 500501
Disjuncts: 1001
Builtins: 0
-- out/eval --
(struct){
f1: (string){ string }
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/cycle.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Retain: 1
Unifications: 15
Conjuncts: 30
Disjuncts: 26
Builtins: 0
-- out/eval --
(struct){
sameValues: (struct){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/decimal.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Retain: 0
Unifications: 11
Conjuncts: 11
Disjuncts: 11
Builtins: 0
-- out/eval --
(struct){
out: (#list){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/deduparc.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Retain: 0
Unifications: 7
Conjuncts: 29
Disjuncts: 11
Builtins: 0
-- out/eval --
(struct){
#Value: (#struct){ |((#struct){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/dedupelem.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Retain: 0
Unifications: 10
Conjuncts: 94
Disjuncts: 16
Builtins: 0
-- out/eval --
Errors:
foo.0: 2 errors in empty disjunction:
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/disjunction.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Retain: 0
Unifications: 4
Conjuncts: 143
Disjuncts: 82
Builtins: 0
-- out/eval --
(struct){
x: (struct){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/issue1684.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Retain: 0
Unifications: 791999
Conjuncts: 2479541
Disjuncts: 1064043
Builtins: 0
-- out/eval --
(struct){
#Secret: (#struct){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/issue2176.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Retain: 1359
Unifications: 4161
Conjuncts: 9489
Disjuncts: 4804
Builtins: 573
-- out/eval --
(struct){
#Datastream: (#struct){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/listdedup.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Retain: 1
Unifications: 18724
Conjuncts: 100730
Disjuncts: 24097
Builtins: 0
-- out/eval --
(struct){
A: (#struct){ |((#struct){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/listdisj.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Retain: 0
Unifications: 287
Conjuncts: 894
Disjuncts: 447
Builtins: 0
-- out/eval --
(struct){
#T: (list){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/mergeddisjunction.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Retain: 0
Unifications: 99
Conjuncts: 530
Disjuncts: 283
Builtins: 0
-- out/eval --
(struct){
list: (#list){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/benchmarks/sort.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Retain: 1
Unifications: 7529
Conjuncts: 12154
Disjuncts: 7530
Builtins: 2
-- out/eval --
(struct){
_a: (#list){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/builtins/056_issue314.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Retain: 17
Unifications: 45
Conjuncts: 77
Disjuncts: 62
Builtins: 16
-- out/eval --
(struct){
x: (#struct){
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/builtins/all.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Retain: 2
Unifications: 14
Conjuncts: 17
Disjuncts: 14
Builtins: 2
-- out/eval --
Errors:
fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/builtins/and.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Retain: 2
Unifications: 6
Conjuncts: 13
Disjuncts: 6
Builtins: 2
-- out/eval --
Errors:
embed.#x: conflicting values 2 and 1:
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/builtins/closed.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Retain: 40
Unifications: 185
Conjuncts: 365
Disjuncts: 190
Builtins: 19
-- out/eval --
Errors:
b.x: field not allowed:
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/builtins/incomplete.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Retain: 53
Unifications: 109
Conjuncts: 266
Disjuncts: 156
Builtins: 32
-- out/eval --
Errors:
badListType.decimal: cannot use 2 (type int) as list in argument 1 to list.Max:
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/builtins/intdiv.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Retain: 0
Unifications: 29
Conjuncts: 29
Disjuncts: 29
Builtins: 28
-- out/eval --
Errors:
quoDivByZero: division by zero:
Expand Down
1 change: 1 addition & 0 deletions cue/testdata/builtins/issue299.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Retain: 0
Unifications: 2
Conjuncts: 5
Disjuncts: 3
Builtins: 0
-- out/eval --
Errors:
x: invalid value ["x","x"] (does not satisfy list.UniqueItems):
Expand Down
Loading