File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,9 @@ public let ObjectiveCBridging = [
76
76
BenchmarkInfo ( name: " ObjectiveCBridgeASCIIStringFromFile " ,
77
77
runFunction: run_ASCIIStringFromFile, tags: ts,
78
78
setUpFunction: setup_ASCIIStringFromFile) ,
79
+ BenchmarkInfo ( name: " UnicodeStringFromCodable " ,
80
+ runFunction: run_UnicodeStringFromCodable, tags: ts,
81
+ setUpFunction: setup_UnicodeStringFromCodable) ,
79
82
]
80
83
81
84
#if _runtime(_ObjC)
@@ -744,3 +747,25 @@ public func run_ASCIIStringFromFile(_ N: Int) {
744
747
#endif
745
748
}
746
749
750
+ var unicodeStringFromCodable : String ? = nil
751
+ var unicodeStringFromCodableDict = [ String: Void] ( )
752
+ public func setup_UnicodeStringFromCodable( ) {
753
+ let jsonString = " [ \( String ( reflecting: string) ) ] "
754
+
755
+ let decoded = try JSONDecoder ( ) . decode ( [ String ] . self, from: Data ( jsonString. utf8) )
756
+ let reEncoded = try JSONEncoder ( ) . encode ( decoded)
757
+ let desc = try JSONDecoder ( ) . decode ( [ String ] . self, from: reEncoded)
758
+
759
+ unicodeStringFromCodable = desc [ 0 ]
760
+ }
761
+
762
+ @inline ( never)
763
+ public func run_UnicodeStringFromCodable( _ N: Int ) {
764
+ #if _runtime(_ObjC)
765
+ for _ in 0 ..< N {
766
+ for _ in 0 ..< 100 {
767
+ unicodeStringFromCodableDict [ identity ( unicodeStringFromCodable) ] = ( )
768
+ }
769
+ }
770
+ #endif
771
+ }
You can’t perform that action at this time.
0 commit comments