-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
161 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2023 The Yorkie Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package types_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/yorkie-team/yorkie/api/types" | ||
"github.com/yorkie-team/yorkie/pkg/document/key" | ||
) | ||
|
||
func TestResourceRefKey(t *testing.T) { | ||
t.Run("DocRefKey Set test", func(t *testing.T) { | ||
docKey := key.Key("docKey") | ||
docID := types.ID("docID") | ||
docRef := types.DocRefKey{} | ||
|
||
// 01. Give an invalid input to Set. | ||
err := docRef.Set("abc") | ||
assert.ErrorIs(t, err, types.ErrInvalidDocRefKeySetInput) | ||
|
||
// 02. Give a valid input to Set. | ||
err = docRef.Set(fmt.Sprintf("%s,%s", docKey, docID)) | ||
assert.NoError(t, err) | ||
assert.Equal(t, docRef.Key, docKey) | ||
assert.Equal(t, docRef.ID, docID) | ||
}) | ||
} |
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
11350c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go Benchmark
BenchmarkDocument/constructor_test - ns/op
1342
ns/op1356
ns/op0.99
BenchmarkDocument/constructor_test - B/op
1208
B/op1208
B/op1
BenchmarkDocument/constructor_test - allocs/op
20
allocs/op20
allocs/op1
BenchmarkDocument/status_test - ns/op
761.2
ns/op786.3
ns/op0.97
BenchmarkDocument/status_test - B/op
1176
B/op1176
B/op1
BenchmarkDocument/status_test - allocs/op
18
allocs/op18
allocs/op1
BenchmarkDocument/equals_test - ns/op
6996
ns/op7138
ns/op0.98
BenchmarkDocument/equals_test - B/op
6913
B/op6913
B/op1
BenchmarkDocument/equals_test - allocs/op
120
allocs/op120
allocs/op1
BenchmarkDocument/nested_update_test - ns/op
15954
ns/op16201
ns/op0.98
BenchmarkDocument/nested_update_test - B/op
11962
B/op11962
B/op1
BenchmarkDocument/nested_update_test - allocs/op
254
allocs/op254
allocs/op1
BenchmarkDocument/delete_test - ns/op
24647
ns/op22198
ns/op1.11
BenchmarkDocument/delete_test - B/op
15188
B/op15188
B/op1
BenchmarkDocument/delete_test - allocs/op
333
allocs/op333
allocs/op1
BenchmarkDocument/object_test - ns/op
8283
ns/op10199
ns/op0.81
BenchmarkDocument/object_test - B/op
6721
B/op6721
B/op1
BenchmarkDocument/object_test - allocs/op
116
allocs/op116
allocs/op1
BenchmarkDocument/array_test - ns/op
29088
ns/op29641
ns/op0.98
BenchmarkDocument/array_test - B/op
11818
B/op11819
B/op1.00
BenchmarkDocument/array_test - allocs/op
270
allocs/op270
allocs/op1
BenchmarkDocument/text_test - ns/op
30915
ns/op31320
ns/op0.99
BenchmarkDocument/text_test - B/op
14797
B/op14795
B/op1.00
BenchmarkDocument/text_test - allocs/op
468
allocs/op468
allocs/op1
BenchmarkDocument/text_composition_test - ns/op
28255
ns/op29237
ns/op0.97
BenchmarkDocument/text_composition_test - B/op
18276
B/op18278
B/op1.00
BenchmarkDocument/text_composition_test - allocs/op
477
allocs/op477
allocs/op1
BenchmarkDocument/rich_text_test - ns/op
80829
ns/op82849
ns/op0.98
BenchmarkDocument/rich_text_test - B/op
38540
B/op38540
B/op1
BenchmarkDocument/rich_text_test - allocs/op
1147
allocs/op1147
allocs/op1
BenchmarkDocument/counter_test - ns/op
16511
ns/op16861
ns/op0.98
BenchmarkDocument/counter_test - B/op
10210
B/op10210
B/op1
BenchmarkDocument/counter_test - allocs/op
236
allocs/op236
allocs/op1
BenchmarkDocument/text_edit_gc_100 - ns/op
2895082
ns/op2985130
ns/op0.97
BenchmarkDocument/text_edit_gc_100 - B/op
1655200
B/op1655239
B/op1.00
BenchmarkDocument/text_edit_gc_100 - allocs/op
17092
allocs/op17092
allocs/op1
BenchmarkDocument/text_edit_gc_1000 - ns/op
230338842
ns/op234174280
ns/op0.98
BenchmarkDocument/text_edit_gc_1000 - B/op
144362084
B/op144368132
B/op1.00
BenchmarkDocument/text_edit_gc_1000 - allocs/op
200987
allocs/op201011
allocs/op1.00
BenchmarkDocument/text_split_gc_100 - ns/op
3369280
ns/op3436736
ns/op0.98
BenchmarkDocument/text_split_gc_100 - B/op
2313472
B/op2313433
B/op1.00
BenchmarkDocument/text_split_gc_100 - allocs/op
16193
allocs/op16193
allocs/op1
BenchmarkDocument/text_split_gc_1000 - ns/op
283955432
ns/op292485836
ns/op0.97
BenchmarkDocument/text_split_gc_1000 - B/op
228903100
B/op228890592
B/op1.00
BenchmarkDocument/text_split_gc_1000 - allocs/op
204006
allocs/op203938
allocs/op1.00
BenchmarkDocument/text_delete_all_10000 - ns/op
10474541
ns/op11958204
ns/op0.88
BenchmarkDocument/text_delete_all_10000 - B/op
5810436
B/op5811760
B/op1.00
BenchmarkDocument/text_delete_all_10000 - allocs/op
40674
allocs/op40681
allocs/op1.00
BenchmarkDocument/text_delete_all_100000 - ns/op
186364327
ns/op192054829
ns/op0.97
BenchmarkDocument/text_delete_all_100000 - B/op
81906656
B/op81904042
B/op1.00
BenchmarkDocument/text_delete_all_100000 - allocs/op
411636
allocs/op411636
allocs/op1
BenchmarkDocument/text_100 - ns/op
220250
ns/op233920
ns/op0.94
BenchmarkDocument/text_100 - B/op
118483
B/op118483
B/op1
BenchmarkDocument/text_100 - allocs/op
5080
allocs/op5080
allocs/op1
BenchmarkDocument/text_1000 - ns/op
2385021
ns/op2472786
ns/op0.96
BenchmarkDocument/text_1000 - B/op
1153070
B/op1153071
B/op1.00
BenchmarkDocument/text_1000 - allocs/op
50084
allocs/op50084
allocs/op1
BenchmarkDocument/array_1000 - ns/op
1199187
ns/op1226516
ns/op0.98
BenchmarkDocument/array_1000 - B/op
1091314
B/op1091288
B/op1.00
BenchmarkDocument/array_1000 - allocs/op
11826
allocs/op11826
allocs/op1
BenchmarkDocument/array_10000 - ns/op
12820982
ns/op13448793
ns/op0.95
BenchmarkDocument/array_10000 - B/op
9799948
B/op9798818
B/op1.00
BenchmarkDocument/array_10000 - allocs/op
120291
allocs/op120286
allocs/op1.00
BenchmarkDocument/array_gc_100 - ns/op
148027
ns/op153630
ns/op0.96
BenchmarkDocument/array_gc_100 - B/op
132481
B/op132479
B/op1.00
BenchmarkDocument/array_gc_100 - allocs/op
1248
allocs/op1248
allocs/op1
BenchmarkDocument/array_gc_1000 - ns/op
1377002
ns/op1430382
ns/op0.96
BenchmarkDocument/array_gc_1000 - B/op
1158902
B/op1158905
B/op1.00
BenchmarkDocument/array_gc_1000 - allocs/op
12864
allocs/op12864
allocs/op1
BenchmarkDocument/counter_1000 - ns/op
203107
ns/op212571
ns/op0.96
BenchmarkDocument/counter_1000 - B/op
192854
B/op192851
B/op1.00
BenchmarkDocument/counter_1000 - allocs/op
5765
allocs/op5765
allocs/op1
BenchmarkDocument/counter_10000 - ns/op
2191169
ns/op2224184
ns/op0.99
BenchmarkDocument/counter_10000 - B/op
2087782
B/op2087765
B/op1.00
BenchmarkDocument/counter_10000 - allocs/op
59772
allocs/op59772
allocs/op1
BenchmarkDocument/object_1000 - ns/op
1345614
ns/op1424367
ns/op0.94
BenchmarkDocument/object_1000 - B/op
1427938
B/op1428068
B/op1.00
BenchmarkDocument/object_1000 - allocs/op
9845
allocs/op9845
allocs/op1
BenchmarkDocument/object_10000 - ns/op
14374897
ns/op14642658
ns/op0.98
BenchmarkDocument/object_10000 - B/op
12167341
B/op12167843
B/op1.00
BenchmarkDocument/object_10000 - allocs/op
100563
allocs/op100562
allocs/op1.00
BenchmarkDocument/tree_100 - ns/op
727544
ns/op744469
ns/op0.98
BenchmarkDocument/tree_100 - B/op
442889
B/op442890
B/op1.00
BenchmarkDocument/tree_100 - allocs/op
4506
allocs/op4506
allocs/op1
BenchmarkDocument/tree_1000 - ns/op
50339337
ns/op50380066
ns/op1.00
BenchmarkDocument/tree_1000 - B/op
35222162
B/op35222527
B/op1.00
BenchmarkDocument/tree_1000 - allocs/op
44118
allocs/op44118
allocs/op1
BenchmarkDocument/tree_10000 - ns/op
6337627467
ns/op6537517333
ns/op0.97
BenchmarkDocument/tree_10000 - B/op
3438874256
B/op3438881024
B/op1.00
BenchmarkDocument/tree_10000 - allocs/op
440203
allocs/op440197
allocs/op1.00
BenchmarkDocument/tree_delete_all_1000 - ns/op
51660324
ns/op50383873
ns/op1.03
BenchmarkDocument/tree_delete_all_1000 - B/op
35687984
B/op35686781
B/op1.00
BenchmarkDocument/tree_delete_all_1000 - allocs/op
51746
allocs/op51744
allocs/op1.00
BenchmarkDocument/tree_edit_gc_100 - ns/op
2726514
ns/op2640190
ns/op1.03
BenchmarkDocument/tree_edit_gc_100 - B/op
2099496
B/op2100192
B/op1.00
BenchmarkDocument/tree_edit_gc_100 - allocs/op
11165
allocs/op11165
allocs/op1
BenchmarkDocument/tree_edit_gc_1000 - ns/op
198299943
ns/op203482588
ns/op0.97
BenchmarkDocument/tree_edit_gc_1000 - B/op
180344660
B/op180290254
B/op1.00
BenchmarkDocument/tree_edit_gc_1000 - allocs/op
113340
allocs/op113352
allocs/op1.00
BenchmarkDocument/tree_split_gc_100 - ns/op
1914138
ns/op1956842
ns/op0.98
BenchmarkDocument/tree_split_gc_100 - B/op
1363441
B/op1363460
B/op1.00
BenchmarkDocument/tree_split_gc_100 - allocs/op
8735
allocs/op8735
allocs/op1
BenchmarkDocument/tree_split_gc_1000 - ns/op
129186380
ns/op135715287
ns/op0.95
BenchmarkDocument/tree_split_gc_1000 - B/op
120284110
B/op120284779
B/op1.00
BenchmarkDocument/tree_split_gc_1000 - allocs/op
96185
allocs/op96190
allocs/op1.00
BenchmarkRPC/client_to_server - ns/op
363158392
ns/op359703488
ns/op1.01
BenchmarkRPC/client_to_server - B/op
12491312
B/op12458544
B/op1.00
BenchmarkRPC/client_to_server - allocs/op
178516
allocs/op176321
allocs/op1.01
BenchmarkRPC/client_to_client_via_server - ns/op
614007609
ns/op603988013
ns/op1.02
BenchmarkRPC/client_to_client_via_server - B/op
23090792
B/op23259432
B/op0.99
BenchmarkRPC/client_to_client_via_server - allocs/op
334602
allocs/op331024
allocs/op1.01
BenchmarkRPC/attach_large_document - ns/op
1304616866
ns/op1381620656
ns/op0.94
BenchmarkRPC/attach_large_document - B/op
1844556352
B/op1820736296
B/op1.01
BenchmarkRPC/attach_large_document - allocs/op
10702
allocs/op10374
allocs/op1.03
BenchmarkRPC/adminCli_to_server - ns/op
504120844
ns/op506711988
ns/op0.99
BenchmarkRPC/adminCli_to_server - B/op
20210692
B/op20155856
B/op1.00
BenchmarkRPC/adminCli_to_server - allocs/op
320732
allocs/op317226
allocs/op1.01
BenchmarkLocker - ns/op
69.8
ns/op67.15
ns/op1.04
BenchmarkLocker - B/op
16
B/op16
B/op1
BenchmarkLocker - allocs/op
1
allocs/op1
allocs/op1
BenchmarkLockerParallel - ns/op
38.82
ns/op41.59
ns/op0.93
BenchmarkLockerParallel - B/op
0
B/op0
B/opNaN
BenchmarkLockerParallel - allocs/op
0
allocs/op0
allocs/opNaN
BenchmarkLockerMoreKeys - ns/op
154.6
ns/op160.5
ns/op0.96
BenchmarkLockerMoreKeys - B/op
15
B/op15
B/op1
BenchmarkLockerMoreKeys - allocs/op
0
allocs/op0
allocs/opNaN
BenchmarkChange/Push_10_Changes - ns/op
4141815
ns/op4228009
ns/op0.98
BenchmarkChange/Push_10_Changes - B/op
147512
B/op147011
B/op1.00
BenchmarkChange/Push_10_Changes - allocs/op
1315
allocs/op1305
allocs/op1.01
BenchmarkChange/Push_100_Changes - ns/op
15521441
ns/op15569560
ns/op1.00
BenchmarkChange/Push_100_Changes - B/op
709135
B/op714288
B/op0.99
BenchmarkChange/Push_100_Changes - allocs/op
6866
allocs/op6857
allocs/op1.00
BenchmarkChange/Push_1000_Changes - ns/op
122473273
ns/op122971913
ns/op1.00
BenchmarkChange/Push_1000_Changes - B/op
6043198
B/op6319134
B/op0.96
BenchmarkChange/Push_1000_Changes - allocs/op
64371
allocs/op64364
allocs/op1.00
BenchmarkChange/Pull_10_Changes - ns/op
3201017
ns/op3266944
ns/op0.98
BenchmarkChange/Pull_10_Changes - B/op
123887
B/op123436
B/op1.00
BenchmarkChange/Pull_10_Changes - allocs/op
1015
allocs/op1006
allocs/op1.01
BenchmarkChange/Pull_100_Changes - ns/op
5045546
ns/op5267253
ns/op0.96
BenchmarkChange/Pull_100_Changes - B/op
327166
B/op325367
B/op1.01
BenchmarkChange/Pull_100_Changes - allocs/op
3486
allocs/op3475
allocs/op1.00
BenchmarkChange/Pull_1000_Changes - ns/op
9614317
ns/op10054426
ns/op0.96
BenchmarkChange/Pull_1000_Changes - B/op
1639942
B/op1636062
B/op1.00
BenchmarkChange/Pull_1000_Changes - allocs/op
29857
allocs/op29837
allocs/op1.00
BenchmarkSnapshot/Push_3KB_snapshot - ns/op
19196260
ns/op19612724
ns/op0.98
BenchmarkSnapshot/Push_3KB_snapshot - B/op
952061
B/op947220
B/op1.01
BenchmarkSnapshot/Push_3KB_snapshot - allocs/op
6873
allocs/op6862
allocs/op1.00
BenchmarkSnapshot/Push_30KB_snapshot - ns/op
127380985
ns/op128964020
ns/op0.99
BenchmarkSnapshot/Push_30KB_snapshot - B/op
6222710
B/op6446989
B/op0.97
BenchmarkSnapshot/Push_30KB_snapshot - allocs/op
64182
allocs/op64177
allocs/op1.00
BenchmarkSnapshot/Pull_3KB_snapshot - ns/op
7563868
ns/op7629068
ns/op0.99
BenchmarkSnapshot/Pull_3KB_snapshot - B/op
1017347
B/op1013744
B/op1.00
BenchmarkSnapshot/Pull_3KB_snapshot - allocs/op
15508
allocs/op15499
allocs/op1.00
BenchmarkSnapshot/Pull_30KB_snapshot - ns/op
16500720
ns/op16093336
ns/op1.03
BenchmarkSnapshot/Pull_30KB_snapshot - B/op
7335702
B/op7331584
B/op1.00
BenchmarkSnapshot/Pull_30KB_snapshot - allocs/op
150124
allocs/op150113
allocs/op1.00
BenchmarkSync/memory_sync_10_test - ns/op
8350
ns/op7126
ns/op1.17
BenchmarkSync/memory_sync_10_test - B/op
1287
B/op1286
B/op1.00
BenchmarkSync/memory_sync_10_test - allocs/op
38
allocs/op38
allocs/op1
BenchmarkSync/memory_sync_100_test - ns/op
52509
ns/op55219
ns/op0.95
BenchmarkSync/memory_sync_100_test - B/op
8651
B/op8990
B/op0.96
BenchmarkSync/memory_sync_100_test - allocs/op
273
allocs/op295
allocs/op0.93
BenchmarkSync/memory_sync_1000_test - ns/op
583911
ns/op440383
ns/op1.33
BenchmarkSync/memory_sync_1000_test - B/op
74603
B/op83572
B/op0.89
BenchmarkSync/memory_sync_1000_test - allocs/op
2126
allocs/op2682
allocs/op0.79
BenchmarkSync/memory_sync_10000_test - ns/op
7157587
ns/op4564967
ns/op1.57
BenchmarkSync/memory_sync_10000_test - B/op
753352
B/op818933
B/op0.92
BenchmarkSync/memory_sync_10000_test - allocs/op
20451
allocs/op24458
allocs/op0.84
BenchmarkTextEditing - ns/op
18552338406
ns/op19066495451
ns/op0.97
BenchmarkTextEditing - B/op
9037758432
B/op9038245440
B/op1.00
BenchmarkTextEditing - allocs/op
19922299
allocs/op19924611
allocs/op1.00
This comment was automatically generated by workflow using github-action-benchmark.