package file_path

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file bench_relative.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
(* See comment in [bench_path.ml]. *)

open! Core

type t = File_path.Relative.t [@@deriving quickcheck, sexp, sexp_grammar]

let arg_type = File_path.Relative.arg_type
let dot = File_path.Relative.dot
let dot_dot = File_path.Relative.dot_dot

include (
  File_path.Relative :
    Identifiable.S
  with type t := t
   and type comparator_witness = File_path.Relative.comparator_witness)

let%bench_fun "equal =" =
  let x = Sys.opaque_identity (of_string "foo/bar/baz") in
  let y = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> equal x y
;;

let%bench_fun "equal <>" =
  let x = Sys.opaque_identity dot in
  let y = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> equal x y
;;

let%bench_fun "compare =" =
  let x = Sys.opaque_identity dot in
  let y = Sys.opaque_identity dot in
  fun () -> compare x y
;;

let%bench_fun "compare <" =
  let x = Sys.opaque_identity dot in
  let y = Sys.opaque_identity dot_dot in
  fun () -> compare x y
;;

let%bench_fun "compare >" =
  let x = Sys.opaque_identity dot_dot in
  let y = Sys.opaque_identity dot in
  fun () -> compare x y
;;

let%bench_fun "of_string, canonical" =
  let string = Sys.opaque_identity "foo/bar/baz" in
  fun () -> of_string string
;;

let%bench_fun "of_string, non-canonical" =
  let string = Sys.opaque_identity "foo//bar/baz/" in
  fun () -> of_string string
;;

let%bench_fun "to_string" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> to_string t
;;

let%bench_fun "t_of_sexp, canonical" =
  let string = Sys.opaque_identity (Sexp.Atom "foo/bar/baz") in
  fun () -> t_of_sexp string
;;

let%bench_fun "t_of_sexp, non-canonical" =
  let string = Sys.opaque_identity (Sexp.Atom "foo//bar/baz/") in
  fun () -> t_of_sexp string
;;

let%bench_fun "sexp_of_t" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> sexp_of_t t
;;

module Expert = struct
  let unchecked_of_canonical_string =
    File_path.Relative.Expert.unchecked_of_canonical_string
  ;;

  let%bench_fun "unchecked_of_canonical_string" =
    let string = Sys.opaque_identity "foo/bar/baz" in
    fun () -> unchecked_of_canonical_string string
  ;;
end

let invariant = File_path.Relative.invariant

let%bench_fun "invariant" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> invariant t
;;

let of_part = File_path.Relative.of_part

let%bench_fun "of_part" =
  let part = Sys.opaque_identity (File_path.Part.of_string "foo") in
  fun () -> of_part part
;;

let basename = File_path.Relative.basename

let%bench_fun "basename" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> basename t
;;

let dirname = File_path.Relative.dirname

let%bench_fun "dirname, some" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> dirname t
;;

let%bench_fun "dirname, none" =
  let t = Sys.opaque_identity (of_string "foo.bar.baz") in
  fun () -> dirname t
;;

let dirname_exn = File_path.Relative.dirname_exn

let%bench_fun "dirname_exn" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> dirname_exn t
;;

let dirname_or_error = File_path.Relative.dirname_or_error

let%bench_fun "dirname_or_error" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> dirname_or_error t
;;

let dirname_defaulting_to_dot = File_path.Relative.dirname_defaulting_to_dot

let%bench_fun "dirname_defaulting_to_dot, dir" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> dirname_defaulting_to_dot t
;;

let%bench_fun "dirname_defaulting_to_dot, dot" =
  let t = Sys.opaque_identity (of_string "foo.bar.baz") in
  fun () -> dirname_defaulting_to_dot t
;;

let top_dir = File_path.Relative.top_dir

let%bench_fun "top_dir, some" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> top_dir t
;;

let%bench_fun "top_dir, none" =
  let t = Sys.opaque_identity dot in
  fun () -> top_dir t
;;

let top_dir_exn = File_path.Relative.top_dir_exn

let%bench_fun "top_dir_exn" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> top_dir_exn t
;;

let top_dir_or_error = File_path.Relative.top_dir_or_error

let%bench_fun "top_dir_or_error" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> top_dir_or_error t
;;

let top_dir_defaulting_to_dot = File_path.Relative.top_dir_defaulting_to_dot

let%bench_fun "top_dir_defaulting_to_dot, dir" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> top_dir_defaulting_to_dot t
;;

let%bench_fun "top_dir_defaulting_to_dot, dot" =
  let t = Sys.opaque_identity dot in
  fun () -> top_dir_defaulting_to_dot t
;;

let all_but_top_dir = File_path.Relative.all_but_top_dir

let%bench_fun "all_but_top_dir, some" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> all_but_top_dir t
;;

let%bench_fun "all_but_top_dir, none" =
  let t = Sys.opaque_identity dot in
  fun () -> all_but_top_dir t
;;

let all_but_top_dir_exn = File_path.Relative.all_but_top_dir_exn

let%bench_fun "all_but_top_dir_exn" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> all_but_top_dir_exn t
;;

let all_but_top_dir_or_error = File_path.Relative.all_but_top_dir_or_error

let%bench_fun "all_but_top_dir_or_error" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> all_but_top_dir_or_error t
;;

let all_but_top_dir_defaulting_to_self =
  File_path.Relative.all_but_top_dir_defaulting_to_self
;;

let%bench_fun "all_but_top_dir_defaulting_to_self, path" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> all_but_top_dir_defaulting_to_self t
;;

let%bench_fun "all_but_top_dir_defaulting_to_self, self" =
  let t = Sys.opaque_identity dot in
  fun () -> all_but_top_dir_defaulting_to_self t
;;

let top_dir_and_all_but_top_dir = File_path.Relative.top_dir_and_all_but_top_dir

let%bench_fun "top_dir_and_all_but_top_dir, some" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> top_dir_and_all_but_top_dir t
;;

let%bench_fun "top_dir_and_all_but_top_dir, none" =
  let t = Sys.opaque_identity dot in
  fun () -> top_dir_and_all_but_top_dir t
;;

let append_to_basename_exn = File_path.Relative.append_to_basename_exn

let%bench_fun "append_to_basename_exn, empty" =
  let t = Sys.opaque_identity (of_string "foo/bar") in
  let suffix = Sys.opaque_identity "" in
  fun () -> append_to_basename_exn t suffix
;;

let%bench_fun "append_to_basename_exn, nonempty" =
  let t = Sys.opaque_identity (of_string "foo/bar") in
  let suffix = Sys.opaque_identity ".baz" in
  fun () -> append_to_basename_exn t suffix
;;

let append_part = File_path.Relative.append_part

let%bench_fun "append_part" =
  let t = Sys.opaque_identity (of_string "foo/bar") in
  let suffix = Sys.opaque_identity (File_path.Part.of_string "baz") in
  fun () -> append_part t suffix
;;

let prepend_part = File_path.Relative.prepend_part

let%bench_fun "prepend_part" =
  let prefix = Sys.opaque_identity (File_path.Part.of_string "foo") in
  let t = Sys.opaque_identity (of_string "bar/baz") in
  fun () -> prepend_part prefix t
;;

let is_prefix = File_path.Relative.is_prefix

let%bench_fun "is_prefix, true" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let prefix = Sys.opaque_identity (of_string "foo/bar") in
  fun () -> is_prefix t ~prefix
;;

let%bench_fun "is_prefix, false" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let prefix = Sys.opaque_identity (of_string "foobie") in
  fun () -> is_prefix t ~prefix
;;

let chop_prefix = File_path.Relative.chop_prefix

let%bench_fun "chop_prefix, some" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let prefix = Sys.opaque_identity (of_string "foo/bar") in
  fun () -> chop_prefix t ~prefix
;;

let%bench_fun "chop_prefix, none" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let prefix = Sys.opaque_identity (of_string "foobie") in
  fun () -> chop_prefix t ~prefix
;;

let chop_prefix_exn = File_path.Relative.chop_prefix_exn

let%bench_fun "chop_prefix_exn" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let prefix = Sys.opaque_identity (of_string "foo/bar") in
  fun () -> chop_prefix_exn t ~prefix
;;

let chop_prefix_or_error = File_path.Relative.chop_prefix_or_error

let%bench_fun "chop_prefix_or_error" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let prefix = Sys.opaque_identity (of_string "foo/bar") in
  fun () -> chop_prefix_or_error t ~prefix
;;

let chop_prefix_if_exists = File_path.Relative.chop_prefix_if_exists

let%bench_fun "chop_prefix_if_exists" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let prefix = Sys.opaque_identity (of_string "foo/bar") in
  fun () -> chop_prefix_if_exists t ~prefix
;;

let is_suffix = File_path.Relative.is_suffix

let%bench_fun "is_suffix, true" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let suffix = Sys.opaque_identity (File_path.Relative.of_string "bar/baz") in
  fun () -> is_suffix t ~suffix
;;

let%bench_fun "is_suffix, false" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let suffix = Sys.opaque_identity (File_path.Relative.of_string "barbie") in
  fun () -> is_suffix t ~suffix
;;

let chop_suffix = File_path.Relative.chop_suffix

let%bench_fun "chop_suffix, some" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let suffix = Sys.opaque_identity (File_path.Relative.of_string "bar/baz") in
  fun () -> chop_suffix t ~suffix
;;

let%bench_fun "chop_suffix, none" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let suffix = Sys.opaque_identity (File_path.Relative.of_string "barbie") in
  fun () -> chop_suffix t ~suffix
;;

let chop_suffix_exn = File_path.Relative.chop_suffix_exn

let%bench_fun "chop_suffix_exn" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let suffix = Sys.opaque_identity (File_path.Relative.of_string "bar/baz") in
  fun () -> chop_suffix_exn t ~suffix
;;

let chop_suffix_or_error = File_path.Relative.chop_suffix_or_error

let%bench_fun "chop_suffix_or_error" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let suffix = Sys.opaque_identity (File_path.Relative.of_string "bar/baz") in
  fun () -> chop_suffix_or_error t ~suffix
;;

let chop_suffix_if_exists = File_path.Relative.chop_suffix_if_exists

let%bench_fun "chop_suffix_if_exists" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  let suffix = Sys.opaque_identity (File_path.Relative.of_string "bar/baz") in
  fun () -> chop_suffix_if_exists t ~suffix
;;

let append = File_path.Relative.append

let%bench_fun "append" =
  let prefix = Sys.opaque_identity (of_string "foo") in
  let suffix = Sys.opaque_identity (File_path.Relative.of_string "bar/baz") in
  fun () -> append prefix suffix
;;

let number_of_parts = File_path.Relative.number_of_parts

let%bench_fun "number_of_parts, dot" =
  let t = Sys.opaque_identity dot in
  fun () -> number_of_parts t
;;

let%bench_fun "number_of_parts, compound" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> number_of_parts t
;;

let to_parts = File_path.Relative.to_parts

let%bench_fun "to_parts, dot" =
  let t = Sys.opaque_identity dot in
  fun () -> to_parts t
;;

let%bench_fun "to_parts, compound" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> to_parts t
;;

let to_parts_nonempty = File_path.Relative.to_parts_nonempty

let%bench_fun "to_parts_nonempty, dot" =
  let t = Sys.opaque_identity dot in
  fun () -> to_parts_nonempty t
;;

let%bench_fun "to_parts_nonempty, compound" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> to_parts_nonempty t
;;

let of_parts = File_path.Relative.of_parts

let%bench_fun "of_parts, empty" =
  let parts = Sys.opaque_identity [] in
  fun () -> of_parts parts
;;

let%bench_fun "of_parts, non-empty" =
  let parts =
    Sys.opaque_identity
      [ File_path.Part.of_string "foo"
      ; File_path.Part.of_string "bar"
      ; File_path.Part.of_string "baz"
      ]
  in
  fun () -> of_parts parts
;;

let of_parts_exn = File_path.Relative.of_parts_exn

let%bench_fun "of_parts_exn" =
  let parts =
    Sys.opaque_identity
      [ File_path.Part.of_string "foo"
      ; File_path.Part.of_string "bar"
      ; File_path.Part.of_string "baz"
      ]
  in
  fun () -> of_parts_exn parts
;;

let of_parts_or_error = File_path.Relative.of_parts_or_error

let%bench_fun "of_parts_or_error" =
  let parts =
    Sys.opaque_identity
      [ File_path.Part.of_string "foo"
      ; File_path.Part.of_string "bar"
      ; File_path.Part.of_string "baz"
      ]
  in
  fun () -> of_parts_or_error parts
;;

let of_parts_defaulting_to_dot = File_path.Relative.of_parts_defaulting_to_dot

let%bench_fun "of_parts_defaulting_to_dot, empty" =
  let parts = Sys.opaque_identity [] in
  fun () -> of_parts_defaulting_to_dot parts
;;

let%bench_fun "of_parts_defaulting_to_dot, non-empty" =
  let parts =
    Sys.opaque_identity
      [ File_path.Part.of_string "foo"
      ; File_path.Part.of_string "bar"
      ; File_path.Part.of_string "baz"
      ]
  in
  fun () -> of_parts_defaulting_to_dot parts
;;

let of_parts_nonempty = File_path.Relative.of_parts_nonempty

let%bench_fun "of_parts_nonempty" =
  let parts =
    Sys.opaque_identity
      ([ File_path.Part.of_string "foo"
       ; File_path.Part.of_string "bar"
       ; File_path.Part.of_string "baz"
       ]
       : _ Nonempty_list.t)
  in
  fun () -> of_parts_nonempty parts
;;

let simplify_dot = File_path.Relative.simplify_dot

let%bench_fun "simplify_dot, unchanged" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> simplify_dot t
;;

let%bench_fun "simplify_dot, changed" =
  let t = Sys.opaque_identity (of_string "./foo/./bar/baz") in
  fun () -> simplify_dot t
;;

let simplify_dot_and_dot_dot_naively = File_path.Relative.simplify_dot_and_dot_dot_naively

let%bench_fun "simplify_dot_and_dot_dot_naively, unchanged" =
  let t = Sys.opaque_identity (of_string "foo/bar/baz") in
  fun () -> simplify_dot_and_dot_dot_naively t
;;

let%bench_fun "simplify_dot_and_dot_dot_naively, changed" =
  let t = Sys.opaque_identity (of_string "./foo/quux/../bar/baz") in
  fun () -> simplify_dot_and_dot_dot_naively t
;;
OCaml

Innovation. Community. Security.