-
-
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.
Introduce types DocRefKey and ClientRefKey
- Loading branch information
Showing
23 changed files
with
999 additions
and
689 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,64 @@ | ||
/* | ||
* 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 | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/yorkie-team/yorkie/pkg/document/key" | ||
) | ||
|
||
// DocRefKey represents an identifier used to reference a document. | ||
type DocRefKey struct { | ||
Key key.Key | ||
ID ID | ||
} | ||
|
||
// String returns the string representation of the given DocRefKey. | ||
func (r *DocRefKey) String() string { | ||
return fmt.Sprintf("Doc (%s.%s)", r.Key, r.ID) | ||
} | ||
|
||
// Set parses the given string (format: `docKey},{docID}`) and assigns the values | ||
// to the given DocRefKey. | ||
func (r *DocRefKey) Set(v string) error { | ||
parsed := strings.Split(v, ",") | ||
if len(parsed) != 2 { | ||
return errors.New("use the format 'docKey,docID' for the input") | ||
} | ||
r.Key = key.Key(parsed[0]) | ||
r.ID = ID(parsed[1]) | ||
return nil | ||
} | ||
|
||
// Type returns the type string of the given DocRefKey, used in cli help text. | ||
func (r *DocRefKey) Type() string { | ||
return "DocumentRefKey" | ||
} | ||
|
||
// ClientRefKey represents an identifier used to reference a client. | ||
type ClientRefKey struct { | ||
Key string | ||
ID ID | ||
} | ||
|
||
// String returns the string representation of the given ClientRefKey. | ||
func (r *ClientRefKey) String() string { | ||
return fmt.Sprintf("Client (%s.%s)", r.Key, r.ID) | ||
} |
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
Oops, something went wrong.
f426bce
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
1332
ns/op1356
ns/op0.98
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
771.3
ns/op786.3
ns/op0.98
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
7062
ns/op7138
ns/op0.99
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
16053
ns/op16201
ns/op0.99
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
21945
ns/op22198
ns/op0.99
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
8288
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
32589
ns/op29641
ns/op1.10
BenchmarkDocument/array_test - B/op
11819
B/op11819
B/op1
BenchmarkDocument/array_test - allocs/op
270
allocs/op270
allocs/op1
BenchmarkDocument/text_test - ns/op
31058
ns/op31320
ns/op0.99
BenchmarkDocument/text_test - B/op
14795
B/op14795
B/op1
BenchmarkDocument/text_test - allocs/op
468
allocs/op468
allocs/op1
BenchmarkDocument/text_composition_test - ns/op
28611
ns/op29237
ns/op0.98
BenchmarkDocument/text_composition_test - B/op
18278
B/op18278
B/op1
BenchmarkDocument/text_composition_test - allocs/op
477
allocs/op477
allocs/op1
BenchmarkDocument/rich_text_test - ns/op
81679
ns/op82849
ns/op0.99
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
16658
ns/op16861
ns/op0.99
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
2887342
ns/op2985130
ns/op0.97
BenchmarkDocument/text_edit_gc_100 - B/op
1655225
B/op1655239
B/op1.00
BenchmarkDocument/text_edit_gc_100 - allocs/op
17093
allocs/op17092
allocs/op1.00
BenchmarkDocument/text_edit_gc_1000 - ns/op
227936520
ns/op234174280
ns/op0.97
BenchmarkDocument/text_edit_gc_1000 - B/op
144342276
B/op144368132
B/op1.00
BenchmarkDocument/text_edit_gc_1000 - allocs/op
200904
allocs/op201011
allocs/op1.00
BenchmarkDocument/text_split_gc_100 - ns/op
3379865
ns/op3436736
ns/op0.98
BenchmarkDocument/text_split_gc_100 - B/op
2313476
B/op2313433
B/op1.00
BenchmarkDocument/text_split_gc_100 - allocs/op
16193
allocs/op16193
allocs/op1
BenchmarkDocument/text_split_gc_1000 - ns/op
284328751
ns/op292485836
ns/op0.97
BenchmarkDocument/text_split_gc_1000 - B/op
228890500
B/op228890592
B/op1.00
BenchmarkDocument/text_split_gc_1000 - allocs/op
203933
allocs/op203938
allocs/op1.00
BenchmarkDocument/text_delete_all_10000 - ns/op
10439057
ns/op11958204
ns/op0.87
BenchmarkDocument/text_delete_all_10000 - B/op
5810989
B/op5811760
B/op1.00
BenchmarkDocument/text_delete_all_10000 - allocs/op
40677
allocs/op40681
allocs/op1.00
BenchmarkDocument/text_delete_all_100000 - ns/op
192013202
ns/op192054829
ns/op1.00
BenchmarkDocument/text_delete_all_100000 - B/op
81890297
B/op81904042
B/op1.00
BenchmarkDocument/text_delete_all_100000 - allocs/op
411583
allocs/op411636
allocs/op1.00
BenchmarkDocument/text_100 - ns/op
234933
ns/op233920
ns/op1.00
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
2444219
ns/op2472786
ns/op0.99
BenchmarkDocument/text_1000 - B/op
1153053
B/op1153071
B/op1.00
BenchmarkDocument/text_1000 - allocs/op
50084
allocs/op50084
allocs/op1
BenchmarkDocument/array_1000 - ns/op
1220582
ns/op1226516
ns/op1.00
BenchmarkDocument/array_1000 - B/op
1091291
B/op1091288
B/op1.00
BenchmarkDocument/array_1000 - allocs/op
11826
allocs/op11826
allocs/op1
BenchmarkDocument/array_10000 - ns/op
13263678
ns/op13448793
ns/op0.99
BenchmarkDocument/array_10000 - B/op
9799627
B/op9798818
B/op1.00
BenchmarkDocument/array_10000 - allocs/op
120289
allocs/op120286
allocs/op1.00
BenchmarkDocument/array_gc_100 - ns/op
155637
ns/op153630
ns/op1.01
BenchmarkDocument/array_gc_100 - B/op
132493
B/op132479
B/op1.00
BenchmarkDocument/array_gc_100 - allocs/op
1248
allocs/op1248
allocs/op1
BenchmarkDocument/array_gc_1000 - ns/op
1435002
ns/op1430382
ns/op1.00
BenchmarkDocument/array_gc_1000 - B/op
1158973
B/op1158905
B/op1.00
BenchmarkDocument/array_gc_1000 - allocs/op
12865
allocs/op12864
allocs/op1.00
BenchmarkDocument/counter_1000 - ns/op
213393
ns/op212571
ns/op1.00
BenchmarkDocument/counter_1000 - B/op
192850
B/op192851
B/op1.00
BenchmarkDocument/counter_1000 - allocs/op
5765
allocs/op5765
allocs/op1
BenchmarkDocument/counter_10000 - ns/op
2230438
ns/op2224184
ns/op1.00
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
1419887
ns/op1424367
ns/op1.00
BenchmarkDocument/object_1000 - B/op
1428015
B/op1428068
B/op1.00
BenchmarkDocument/object_1000 - allocs/op
9845
allocs/op9845
allocs/op1
BenchmarkDocument/object_10000 - ns/op
14548988
ns/op14642658
ns/op0.99
BenchmarkDocument/object_10000 - B/op
12167118
B/op12167843
B/op1.00
BenchmarkDocument/object_10000 - allocs/op
100562
allocs/op100562
allocs/op1
BenchmarkDocument/tree_100 - ns/op
756301
ns/op744469
ns/op1.02
BenchmarkDocument/tree_100 - B/op
442890
B/op442890
B/op1
BenchmarkDocument/tree_100 - allocs/op
4506
allocs/op4506
allocs/op1
BenchmarkDocument/tree_1000 - ns/op
53306879
ns/op50380066
ns/op1.06
BenchmarkDocument/tree_1000 - B/op
35222212
B/op35222527
B/op1.00
BenchmarkDocument/tree_1000 - allocs/op
44119
allocs/op44118
allocs/op1.00
BenchmarkDocument/tree_10000 - ns/op
6714295291
ns/op6537517333
ns/op1.03
BenchmarkDocument/tree_10000 - B/op
3438882224
B/op3438881024
B/op1.00
BenchmarkDocument/tree_10000 - allocs/op
440206
allocs/op440197
allocs/op1.00
BenchmarkDocument/tree_delete_all_1000 - ns/op
53818638
ns/op50383873
ns/op1.07
BenchmarkDocument/tree_delete_all_1000 - B/op
35702266
B/op35686781
B/op1.00
BenchmarkDocument/tree_delete_all_1000 - allocs/op
51743
allocs/op51744
allocs/op1.00
BenchmarkDocument/tree_edit_gc_100 - ns/op
2726314
ns/op2640190
ns/op1.03
BenchmarkDocument/tree_edit_gc_100 - B/op
2099486
B/op2100192
B/op1.00
BenchmarkDocument/tree_edit_gc_100 - allocs/op
11165
allocs/op11165
allocs/op1
BenchmarkDocument/tree_edit_gc_1000 - ns/op
212286989
ns/op203482588
ns/op1.04
BenchmarkDocument/tree_edit_gc_1000 - B/op
180291390
B/op180290254
B/op1.00
BenchmarkDocument/tree_edit_gc_1000 - allocs/op
113348
allocs/op113352
allocs/op1.00
BenchmarkDocument/tree_split_gc_100 - ns/op
1988711
ns/op1956842
ns/op1.02
BenchmarkDocument/tree_split_gc_100 - B/op
1363432
B/op1363460
B/op1.00
BenchmarkDocument/tree_split_gc_100 - allocs/op
8735
allocs/op8735
allocs/op1
BenchmarkDocument/tree_split_gc_1000 - ns/op
137834008
ns/op135715287
ns/op1.02
BenchmarkDocument/tree_split_gc_1000 - B/op
120283599
B/op120284779
B/op1.00
BenchmarkDocument/tree_split_gc_1000 - allocs/op
96191
allocs/op96190
allocs/op1.00
BenchmarkRPC/client_to_server - ns/op
363470292
ns/op359703488
ns/op1.01
BenchmarkRPC/client_to_server - B/op
12487818
B/op12458544
B/op1.00
BenchmarkRPC/client_to_server - allocs/op
178504
allocs/op176321
allocs/op1.01
BenchmarkRPC/client_to_client_via_server - ns/op
616172911
ns/op603988013
ns/op1.02
BenchmarkRPC/client_to_client_via_server - B/op
23122672
B/op23259432
B/op0.99
BenchmarkRPC/client_to_client_via_server - allocs/op
335142
allocs/op331024
allocs/op1.01
BenchmarkRPC/attach_large_document - ns/op
1178572005
ns/op1381620656
ns/op0.85
BenchmarkRPC/attach_large_document - B/op
1823491904
B/op1820736296
B/op1.00
BenchmarkRPC/attach_large_document - allocs/op
10858
allocs/op10374
allocs/op1.05
BenchmarkRPC/adminCli_to_server - ns/op
506500148
ns/op506711988
ns/op1.00
BenchmarkRPC/adminCli_to_server - B/op
20212776
B/op20155856
B/op1.00
BenchmarkRPC/adminCli_to_server - allocs/op
320758
allocs/op317226
allocs/op1.01
BenchmarkLocker - ns/op
71.4
ns/op67.15
ns/op1.06
BenchmarkLocker - B/op
16
B/op16
B/op1
BenchmarkLocker - allocs/op
1
allocs/op1
allocs/op1
BenchmarkLockerParallel - ns/op
39.74
ns/op41.59
ns/op0.96
BenchmarkLockerParallel - B/op
0
B/op0
B/opNaN
BenchmarkLockerParallel - allocs/op
0
allocs/op0
allocs/opNaN
BenchmarkLockerMoreKeys - ns/op
156.9
ns/op160.5
ns/op0.98
BenchmarkLockerMoreKeys - B/op
15
B/op15
B/op1
BenchmarkLockerMoreKeys - allocs/op
0
allocs/op0
allocs/opNaN
BenchmarkChange/Push_10_Changes - ns/op
4156904
ns/op4228009
ns/op0.98
BenchmarkChange/Push_10_Changes - B/op
147050
B/op147011
B/op1.00
BenchmarkChange/Push_10_Changes - allocs/op
1315
allocs/op1305
allocs/op1.01
BenchmarkChange/Push_100_Changes - ns/op
15440690
ns/op15569560
ns/op0.99
BenchmarkChange/Push_100_Changes - B/op
704206
B/op714288
B/op0.99
BenchmarkChange/Push_100_Changes - allocs/op
6868
allocs/op6857
allocs/op1.00
BenchmarkChange/Push_1000_Changes - ns/op
122415651
ns/op122971913
ns/op1.00
BenchmarkChange/Push_1000_Changes - B/op
6168200
B/op6319134
B/op0.98
BenchmarkChange/Push_1000_Changes - allocs/op
64375
allocs/op64364
allocs/op1.00
BenchmarkChange/Pull_10_Changes - ns/op
3216200
ns/op3266944
ns/op0.98
BenchmarkChange/Pull_10_Changes - B/op
124234
B/op123436
B/op1.01
BenchmarkChange/Pull_10_Changes - allocs/op
1015
allocs/op1006
allocs/op1.01
BenchmarkChange/Pull_100_Changes - ns/op
5085369
ns/op5267253
ns/op0.97
BenchmarkChange/Pull_100_Changes - B/op
327377
B/op325367
B/op1.01
BenchmarkChange/Pull_100_Changes - allocs/op
3484
allocs/op3475
allocs/op1.00
BenchmarkChange/Pull_1000_Changes - ns/op
9786770
ns/op10054426
ns/op0.97
BenchmarkChange/Pull_1000_Changes - B/op
1639694
B/op1636062
B/op1.00
BenchmarkChange/Pull_1000_Changes - allocs/op
29855
allocs/op29837
allocs/op1.00
BenchmarkSnapshot/Push_3KB_snapshot - ns/op
19546815
ns/op19612724
ns/op1.00
BenchmarkSnapshot/Push_3KB_snapshot - B/op
952246
B/op947220
B/op1.01
BenchmarkSnapshot/Push_3KB_snapshot - allocs/op
6872
allocs/op6862
allocs/op1.00
BenchmarkSnapshot/Push_30KB_snapshot - ns/op
128227344
ns/op128964020
ns/op0.99
BenchmarkSnapshot/Push_30KB_snapshot - B/op
6321645
B/op6446989
B/op0.98
BenchmarkSnapshot/Push_30KB_snapshot - allocs/op
64185
allocs/op64177
allocs/op1.00
BenchmarkSnapshot/Pull_3KB_snapshot - ns/op
7505222
ns/op7629068
ns/op0.98
BenchmarkSnapshot/Pull_3KB_snapshot - B/op
1017365
B/op1013744
B/op1.00
BenchmarkSnapshot/Pull_3KB_snapshot - allocs/op
15508
allocs/op15499
allocs/op1.00
BenchmarkSnapshot/Pull_30KB_snapshot - ns/op
15701727
ns/op16093336
ns/op0.98
BenchmarkSnapshot/Pull_30KB_snapshot - B/op
7332663
B/op7331584
B/op1.00
BenchmarkSnapshot/Pull_30KB_snapshot - allocs/op
150122
allocs/op150113
allocs/op1.00
BenchmarkSync/memory_sync_10_test - ns/op
6982
ns/op7126
ns/op0.98
BenchmarkSync/memory_sync_10_test - B/op
1286
B/op1286
B/op1
BenchmarkSync/memory_sync_10_test - allocs/op
38
allocs/op38
allocs/op1
BenchmarkSync/memory_sync_100_test - ns/op
52893
ns/op55219
ns/op0.96
BenchmarkSync/memory_sync_100_test - B/op
8633
B/op8990
B/op0.96
BenchmarkSync/memory_sync_100_test - allocs/op
272
allocs/op295
allocs/op0.92
BenchmarkSync/memory_sync_1000_test - ns/op
578730
ns/op440383
ns/op1.31
BenchmarkSync/memory_sync_1000_test - B/op
75033
B/op83572
B/op0.90
BenchmarkSync/memory_sync_1000_test - allocs/op
2149
allocs/op2682
allocs/op0.80
BenchmarkSync/memory_sync_10000_test - ns/op
7135952
ns/op4564967
ns/op1.56
BenchmarkSync/memory_sync_10000_test - B/op
759502
B/op818933
B/op0.93
BenchmarkSync/memory_sync_10000_test - allocs/op
20573
allocs/op24458
allocs/op0.84
BenchmarkTextEditing - ns/op
19168412338
ns/op19066495451
ns/op1.01
BenchmarkTextEditing - B/op
9037729184
B/op9038245440
B/op1.00
BenchmarkTextEditing - allocs/op
19922153
allocs/op19924611
allocs/op1.00
This comment was automatically generated by workflow using github-action-benchmark.