@@ -73,6 +73,9 @@ public let ObjectiveCBridging = [
73
73
BenchmarkInfo ( name: " ObjectiveCBridgeFromNSDateComponents " ,
74
74
runFunction: run_ObjectiveCBridgeFromNSDateComponents, tags: t,
75
75
setUpFunction: setup_dateComponents) ,
76
+ BenchmarkInfo ( name: " ObjectiveCBridgeASCIIStringFromFile " ,
77
+ runFunction: run_ASCIIStringFromFile, tags: ts,
78
+ setUpFunction: setup_ASCIIStringFromFile) ,
76
79
]
77
80
78
81
#if _runtime(_ObjC)
@@ -709,3 +712,35 @@ public func run_ObjectiveCBridgeFromNSDateComponents(_ N: Int) {
709
712
}
710
713
#endif
711
714
}
715
+
716
+ var ASCIIStringFromFile : String ? = nil
717
+ public func setup_ASCIIStringFromFile( ) {
718
+ #if _runtime(_ObjC)
719
+ let url : URL
720
+ if #available( OSX 10 . 12 , iOS 10 . 0 , tvOS 10 . 0 , watchOS 3 . 0 , * ) {
721
+ url = FileManager . default. temporaryDirectory. appendingPathComponent (
722
+ " sphinx.txt "
723
+ )
724
+ } else {
725
+ url = URL ( fileURLWithPath: " /tmp/sphinx.txt " )
726
+ }
727
+ var str = " Sphinx of black quartz judge my vow "
728
+ str = Array ( repeating: str, count: 100 ) . joined ( )
729
+ try ? str. write (
730
+ to: url,
731
+ atomically: true ,
732
+ encoding: . ascii
733
+ )
734
+ ASCIIStringFromFile = try ! String ( contentsOf: url, encoding: . ascii)
735
+ #endif
736
+ }
737
+
738
+ @inline ( never)
739
+ public func run_ASCIIStringFromFile( _ N: Int ) {
740
+ #if _runtime(_ObjC)
741
+ for _ in 0 ..< N {
742
+ blackHole ( ( ASCIIStringFromFile! + " " ) . utf8. count)
743
+ }
744
+ #endif
745
+ }
746
+
0 commit comments