Skip to content

Commit

Permalink
Add test for converting array to bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
chacha912 committed Nov 21, 2023
1 parent 10ef0af commit a85ff4b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions api/converter/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,28 @@ func TestConverter(t *testing.T) {
assert.Equal(t, tree.ToXML(), clone.ToXML())
})

t.Run("array converting to bytes test", func(t *testing.T) {
root := helper.TestRoot()
ctx := helper.TextChangeContext(root)

treeList := crdt.NewRGATreeList()
arr := crdt.NewArray(treeList, ctx.IssueTimeTicket())
primitive, _ := crdt.NewPrimitive("1", ctx.IssueTimeTicket())
_ = arr.Add(primitive)
primitive, _ = crdt.NewPrimitive("2", ctx.IssueTimeTicket())
_ = arr.Add(primitive)
primitive, _ = crdt.NewPrimitive("3", ctx.IssueTimeTicket())
_ = arr.Add(primitive)

bytes, err := converter.ArrayToBytes(arr)
assert.NoError(t, err)
clone, err := converter.BytesToArray(bytes)
assert.NoError(t, err)

assert.Equal(t, `["1","2","3"]`, arr.Marshal())
assert.Equal(t, `["1","2","3"]`, clone.Marshal())
})

t.Run("empty presence converting test", func(t *testing.T) {
change, err := innerpresence.NewChangeFromJSON(`{"ChangeType":"put","Presence":{}}`)
assert.NoError(t, err)
Expand Down

1 comment on commit a85ff4b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go Benchmark

Benchmark suite Current: a85ff4b Previous: 10ef0af Ratio
BenchmarkDocument/constructor_test - ns/op 1355 ns/op 1488 ns/op 0.91
BenchmarkDocument/constructor_test - B/op 1208 B/op 1208 B/op 1
BenchmarkDocument/constructor_test - allocs/op 20 allocs/op 20 allocs/op 1
BenchmarkDocument/status_test - ns/op 762 ns/op 784.1 ns/op 0.97
BenchmarkDocument/status_test - B/op 1176 B/op 1176 B/op 1
BenchmarkDocument/status_test - allocs/op 18 allocs/op 18 allocs/op 1
BenchmarkDocument/equals_test - ns/op 7019 ns/op 7051 ns/op 1.00
BenchmarkDocument/equals_test - B/op 6913 B/op 6913 B/op 1
BenchmarkDocument/equals_test - allocs/op 120 allocs/op 120 allocs/op 1
BenchmarkDocument/nested_update_test - ns/op 15993 ns/op 16134 ns/op 0.99
BenchmarkDocument/nested_update_test - B/op 11962 B/op 11963 B/op 1.00
BenchmarkDocument/nested_update_test - allocs/op 254 allocs/op 254 allocs/op 1
BenchmarkDocument/delete_test - ns/op 21826 ns/op 21934 ns/op 1.00
BenchmarkDocument/delete_test - B/op 15188 B/op 15188 B/op 1
BenchmarkDocument/delete_test - allocs/op 333 allocs/op 333 allocs/op 1
BenchmarkDocument/object_test - ns/op 8298 ns/op 8286 ns/op 1.00
BenchmarkDocument/object_test - B/op 6721 B/op 6721 B/op 1
BenchmarkDocument/object_test - allocs/op 116 allocs/op 116 allocs/op 1
BenchmarkDocument/array_test - ns/op 28530 ns/op 28774 ns/op 0.99
BenchmarkDocument/array_test - B/op 11819 B/op 11818 B/op 1.00
BenchmarkDocument/array_test - allocs/op 270 allocs/op 270 allocs/op 1
BenchmarkDocument/text_test - ns/op 34203 ns/op 30569 ns/op 1.12
BenchmarkDocument/text_test - B/op 14795 B/op 14795 B/op 1
BenchmarkDocument/text_test - allocs/op 468 allocs/op 468 allocs/op 1
BenchmarkDocument/text_composition_test - ns/op 28421 ns/op 28544 ns/op 1.00
BenchmarkDocument/text_composition_test - B/op 18278 B/op 18278 B/op 1
BenchmarkDocument/text_composition_test - allocs/op 477 allocs/op 477 allocs/op 1
BenchmarkDocument/rich_text_test - ns/op 81543 ns/op 80785 ns/op 1.01
BenchmarkDocument/rich_text_test - B/op 38540 B/op 38539 B/op 1.00
BenchmarkDocument/rich_text_test - allocs/op 1147 allocs/op 1147 allocs/op 1
BenchmarkDocument/counter_test - ns/op 16278 ns/op 16566 ns/op 0.98
BenchmarkDocument/counter_test - B/op 10210 B/op 10210 B/op 1
BenchmarkDocument/counter_test - allocs/op 236 allocs/op 236 allocs/op 1
BenchmarkDocument/text_edit_gc_100 - ns/op 2873679 ns/op 2939098 ns/op 0.98
BenchmarkDocument/text_edit_gc_100 - B/op 1655238 B/op 1655407 B/op 1.00
BenchmarkDocument/text_edit_gc_100 - allocs/op 17093 allocs/op 17093 allocs/op 1
BenchmarkDocument/text_edit_gc_1000 - ns/op 226376652 ns/op 230413475 ns/op 0.98
BenchmarkDocument/text_edit_gc_1000 - B/op 144352827 B/op 144365604 B/op 1.00
BenchmarkDocument/text_edit_gc_1000 - allocs/op 200936 allocs/op 201000 allocs/op 1.00
BenchmarkDocument/text_split_gc_100 - ns/op 3334024 ns/op 3393132 ns/op 0.98
BenchmarkDocument/text_split_gc_100 - B/op 2313535 B/op 2313643 B/op 1.00
BenchmarkDocument/text_split_gc_100 - allocs/op 16195 allocs/op 16194 allocs/op 1.00
BenchmarkDocument/text_split_gc_1000 - ns/op 287801460 ns/op 288213918 ns/op 1.00
BenchmarkDocument/text_split_gc_1000 - B/op 228896500 B/op 228907952 B/op 1.00
BenchmarkDocument/text_split_gc_1000 - allocs/op 203971 allocs/op 204030 allocs/op 1.00
BenchmarkDocument/text_delete_all_10000 - ns/op 10521415 ns/op 10817436 ns/op 0.97
BenchmarkDocument/text_delete_all_10000 - B/op 5810705 B/op 5810188 B/op 1.00
BenchmarkDocument/text_delete_all_10000 - allocs/op 40676 allocs/op 40674 allocs/op 1.00
BenchmarkDocument/text_delete_all_100000 - ns/op 183491980 ns/op 191610049 ns/op 0.96
BenchmarkDocument/text_delete_all_100000 - B/op 81892938 B/op 81895673 B/op 1.00
BenchmarkDocument/text_delete_all_100000 - allocs/op 411589 allocs/op 411602 allocs/op 1.00
BenchmarkDocument/text_100 - ns/op 230911 ns/op 219994 ns/op 1.05
BenchmarkDocument/text_100 - B/op 118483 B/op 118481 B/op 1.00
BenchmarkDocument/text_100 - allocs/op 5080 allocs/op 5080 allocs/op 1
BenchmarkDocument/text_1000 - ns/op 2451381 ns/op 2406405 ns/op 1.02
BenchmarkDocument/text_1000 - B/op 1153071 B/op 1153054 B/op 1.00
BenchmarkDocument/text_1000 - allocs/op 50084 allocs/op 50084 allocs/op 1
BenchmarkDocument/array_1000 - ns/op 1225411 ns/op 1167007 ns/op 1.05
BenchmarkDocument/array_1000 - B/op 1091239 B/op 1091235 B/op 1.00
BenchmarkDocument/array_1000 - allocs/op 11825 allocs/op 11825 allocs/op 1
BenchmarkDocument/array_10000 - ns/op 12946457 ns/op 12839456 ns/op 1.01
BenchmarkDocument/array_10000 - B/op 9799505 B/op 9799830 B/op 1.00
BenchmarkDocument/array_10000 - allocs/op 120289 allocs/op 120291 allocs/op 1.00
BenchmarkDocument/array_gc_100 - ns/op 151311 ns/op 141341 ns/op 1.07
BenchmarkDocument/array_gc_100 - B/op 132495 B/op 132492 B/op 1.00
BenchmarkDocument/array_gc_100 - allocs/op 1248 allocs/op 1248 allocs/op 1
BenchmarkDocument/array_gc_1000 - ns/op 1401953 ns/op 1348431 ns/op 1.04
BenchmarkDocument/array_gc_1000 - B/op 1158892 B/op 1158846 B/op 1.00
BenchmarkDocument/array_gc_1000 - allocs/op 12864 allocs/op 12864 allocs/op 1
BenchmarkDocument/counter_1000 - ns/op 208427 ns/op 197167 ns/op 1.06
BenchmarkDocument/counter_1000 - B/op 192853 B/op 192852 B/op 1.00
BenchmarkDocument/counter_1000 - allocs/op 5765 allocs/op 5765 allocs/op 1
BenchmarkDocument/counter_10000 - ns/op 2203735 ns/op 2196543 ns/op 1.00
BenchmarkDocument/counter_10000 - B/op 2087767 B/op 2087781 B/op 1.00
BenchmarkDocument/counter_10000 - allocs/op 59772 allocs/op 59772 allocs/op 1
BenchmarkDocument/object_1000 - ns/op 1397542 ns/op 1333033 ns/op 1.05
BenchmarkDocument/object_1000 - B/op 1428095 B/op 1428047 B/op 1.00
BenchmarkDocument/object_1000 - allocs/op 9845 allocs/op 9845 allocs/op 1
BenchmarkDocument/object_10000 - ns/op 14301267 ns/op 14483706 ns/op 0.99
BenchmarkDocument/object_10000 - B/op 12166182 B/op 12166294 B/op 1.00
BenchmarkDocument/object_10000 - allocs/op 100560 allocs/op 100561 allocs/op 1.00
BenchmarkDocument/tree_100 - ns/op 721503 ns/op 680790 ns/op 1.06
BenchmarkDocument/tree_100 - B/op 442889 B/op 442889 B/op 1
BenchmarkDocument/tree_100 - allocs/op 4506 allocs/op 4506 allocs/op 1
BenchmarkDocument/tree_1000 - ns/op 48316327 ns/op 45574042 ns/op 1.06
BenchmarkDocument/tree_1000 - B/op 35222835 B/op 35222215 B/op 1.00
BenchmarkDocument/tree_1000 - allocs/op 44119 allocs/op 44119 allocs/op 1
BenchmarkDocument/tree_10000 - ns/op 6332647945 ns/op 6141330354 ns/op 1.03
BenchmarkDocument/tree_10000 - B/op 3439185440 B/op 3439201792 B/op 1.00
BenchmarkDocument/tree_10000 - allocs/op 440204 allocs/op 440203 allocs/op 1.00
BenchmarkDocument/tree_delete_all_1000 - ns/op 49081042 ns/op 46475796 ns/op 1.06
BenchmarkDocument/tree_delete_all_1000 - B/op 35687417 B/op 35687295 B/op 1.00
BenchmarkDocument/tree_delete_all_1000 - allocs/op 51745 allocs/op 51745 allocs/op 1
BenchmarkDocument/tree_edit_gc_100 - ns/op 2614316 ns/op 2518582 ns/op 1.04
BenchmarkDocument/tree_edit_gc_100 - B/op 2099493 B/op 2099464 B/op 1.00
BenchmarkDocument/tree_edit_gc_100 - allocs/op 11165 allocs/op 11165 allocs/op 1
BenchmarkDocument/tree_edit_gc_1000 - ns/op 195668108 ns/op 190747753 ns/op 1.03
BenchmarkDocument/tree_edit_gc_1000 - B/op 180290894 B/op 180290390 B/op 1.00
BenchmarkDocument/tree_edit_gc_1000 - allocs/op 113348 allocs/op 113345 allocs/op 1.00
BenchmarkDocument/tree_split_gc_100 - ns/op 1950029 ns/op 1841536 ns/op 1.06
BenchmarkDocument/tree_split_gc_100 - B/op 1363442 B/op 1363427 B/op 1.00
BenchmarkDocument/tree_split_gc_100 - allocs/op 8735 allocs/op 8735 allocs/op 1
BenchmarkDocument/tree_split_gc_1000 - ns/op 132186007 ns/op 122820849 ns/op 1.08
BenchmarkDocument/tree_split_gc_1000 - B/op 120283098 B/op 120283632 B/op 1.00
BenchmarkDocument/tree_split_gc_1000 - allocs/op 96188 allocs/op 96183 allocs/op 1.00
BenchmarkRPC/client_to_server - ns/op 354957511 ns/op 354814859 ns/op 1.00
BenchmarkRPC/client_to_server - B/op 12316738 B/op 12313989 B/op 1.00
BenchmarkRPC/client_to_server - allocs/op 172787 allocs/op 172792 allocs/op 1.00
BenchmarkRPC/client_to_client_via_server - ns/op 592646708 ns/op 599768970 ns/op 0.99
BenchmarkRPC/client_to_client_via_server - B/op 22692328 B/op 22775644 B/op 1.00
BenchmarkRPC/client_to_client_via_server - allocs/op 323417 allocs/op 324586 allocs/op 1.00
BenchmarkRPC/attach_large_document - ns/op 1146410404 ns/op 1053858038 ns/op 1.09
BenchmarkRPC/attach_large_document - B/op 1818064856 B/op 1796352520 B/op 1.01
BenchmarkRPC/attach_large_document - allocs/op 10253 allocs/op 10712 allocs/op 0.96
BenchmarkRPC/adminCli_to_server - ns/op 502532056 ns/op 509044021 ns/op 0.99
BenchmarkRPC/adminCli_to_server - B/op 20186460 B/op 20194464 B/op 1.00
BenchmarkRPC/adminCli_to_server - allocs/op 318205 allocs/op 318251 allocs/op 1.00
BenchmarkLocker - ns/op 63.56 ns/op 64.82 ns/op 0.98
BenchmarkLocker - B/op 16 B/op 16 B/op 1
BenchmarkLocker - allocs/op 1 allocs/op 1 allocs/op 1
BenchmarkLockerParallel - ns/op 38 ns/op 38.88 ns/op 0.98
BenchmarkLockerParallel - B/op 0 B/op 0 B/op NaN
BenchmarkLockerParallel - allocs/op 0 allocs/op 0 allocs/op NaN
BenchmarkLockerMoreKeys - ns/op 144.3 ns/op 147.7 ns/op 0.98
BenchmarkLockerMoreKeys - B/op 15 B/op 15 B/op 1
BenchmarkLockerMoreKeys - allocs/op 0 allocs/op 0 allocs/op NaN
BenchmarkChange/Push_10_Changes - ns/op 3778074 ns/op 3838245 ns/op 0.98
BenchmarkChange/Push_10_Changes - B/op 125681 B/op 125419 B/op 1.00
BenchmarkChange/Push_10_Changes - allocs/op 1254 allocs/op 1253 allocs/op 1.00
BenchmarkChange/Push_100_Changes - ns/op 13953061 ns/op 14240274 ns/op 0.98
BenchmarkChange/Push_100_Changes - B/op 643934 B/op 637472 B/op 1.01
BenchmarkChange/Push_100_Changes - allocs/op 6539 allocs/op 6539 allocs/op 1
BenchmarkChange/Push_1000_Changes - ns/op 111976583 ns/op 114033632 ns/op 0.98
BenchmarkChange/Push_1000_Changes - B/op 6086280 B/op 6053229 B/op 1.01
BenchmarkChange/Push_1000_Changes - allocs/op 62156 allocs/op 62159 allocs/op 1.00
BenchmarkChange/Pull_10_Changes - ns/op 2869823 ns/op 2913567 ns/op 0.98
BenchmarkChange/Pull_10_Changes - B/op 100853 B/op 100319 B/op 1.01
BenchmarkChange/Pull_10_Changes - allocs/op 952 allocs/op 952 allocs/op 1
BenchmarkChange/Pull_100_Changes - ns/op 4375636 ns/op 4463212 ns/op 0.98
BenchmarkChange/Pull_100_Changes - B/op 258239 B/op 256830 B/op 1.01
BenchmarkChange/Pull_100_Changes - allocs/op 3154 allocs/op 3153 allocs/op 1.00
BenchmarkChange/Pull_1000_Changes - ns/op 8329315 ns/op 8680896 ns/op 0.96
BenchmarkChange/Pull_1000_Changes - B/op 1398440 B/op 1391823 B/op 1.00
BenchmarkChange/Pull_1000_Changes - allocs/op 26869 allocs/op 26863 allocs/op 1.00
BenchmarkSnapshot/Push_3KB_snapshot - ns/op 16450046 ns/op 17124193 ns/op 0.96
BenchmarkSnapshot/Push_3KB_snapshot - B/op 801924 B/op 795662 B/op 1.01
BenchmarkSnapshot/Push_3KB_snapshot - allocs/op 6540 allocs/op 6541 allocs/op 1.00
BenchmarkSnapshot/Push_30KB_snapshot - ns/op 116883485 ns/op 118550380 ns/op 0.99
BenchmarkSnapshot/Push_30KB_snapshot - B/op 6306355 B/op 6092004 B/op 1.04
BenchmarkSnapshot/Push_30KB_snapshot - allocs/op 62161 allocs/op 62351 allocs/op 1.00
BenchmarkSnapshot/Pull_3KB_snapshot - ns/op 6481538 ns/op 6682125 ns/op 0.97
BenchmarkSnapshot/Pull_3KB_snapshot - B/op 894896 B/op 893100 B/op 1.00
BenchmarkSnapshot/Pull_3KB_snapshot - allocs/op 14877 allocs/op 14878 allocs/op 1.00
BenchmarkSnapshot/Pull_30KB_snapshot - ns/op 14157006 ns/op 14320788 ns/op 0.99
BenchmarkSnapshot/Pull_30KB_snapshot - B/op 6890814 B/op 6885147 B/op 1.00
BenchmarkSnapshot/Pull_30KB_snapshot - allocs/op 144139 allocs/op 144139 allocs/op 1
BenchmarkSync/memory_sync_10_test - ns/op 6661 ns/op 6890 ns/op 0.97
BenchmarkSync/memory_sync_10_test - B/op 1286 B/op 1286 B/op 1
BenchmarkSync/memory_sync_10_test - allocs/op 38 allocs/op 38 allocs/op 1
BenchmarkSync/memory_sync_100_test - ns/op 51268 ns/op 51823 ns/op 0.99
BenchmarkSync/memory_sync_100_test - B/op 8652 B/op 8653 B/op 1.00
BenchmarkSync/memory_sync_100_test - allocs/op 273 allocs/op 273 allocs/op 1
BenchmarkSync/memory_sync_1000_test - ns/op 594166 ns/op 599565 ns/op 0.99
BenchmarkSync/memory_sync_1000_test - B/op 74394 B/op 74417 B/op 1.00
BenchmarkSync/memory_sync_1000_test - allocs/op 2112 allocs/op 2112 allocs/op 1
BenchmarkSync/memory_sync_10000_test - ns/op 7074246 ns/op 7298454 ns/op 0.97
BenchmarkSync/memory_sync_10000_test - B/op 764098 B/op 758673 B/op 1.01
BenchmarkSync/memory_sync_10000_test - allocs/op 20559 allocs/op 20563 allocs/op 1.00
BenchmarkTextEditing - ns/op 18382521571 ns/op 18965669662 ns/op 0.97
BenchmarkTextEditing - B/op 9037805536 B/op 9037913976 B/op 1.00
BenchmarkTextEditing - allocs/op 19922472 allocs/op 19922963 allocs/op 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.