Skip to content

Commit 3a3f857

Browse files
committed
Add example for ontract-profile-thunk, and relocate existing examples.
1 parent 277aa19 commit 3a3f857

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

scribblings/contract-profile.scrbl

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,6 @@ arguments which specify their destination files. An argument of @racket[#f]
107107
}
108108
]
109109

110-
}
111-
112-
@defproc[(contract-profile-thunk
113-
[thunk (-> any)]
114-
[#:module-graph-view-file module-graph-view-file (or/c path-string #f) #f]
115-
[#:boundary-view-file boundary-view-file (or/c path-string #f) #f]
116-
[#:boundary-view-key-file boundary-view-key-file (or/c path-string #f) #f]
117-
[#:report-space-efficient? report-space-efficient? any/c #f])
118-
any]{
119-
Like @racket[contract-profile], but as a function which takes a thunk to
120-
profile as argument.
121-
}
122-
123-
124110
@examples[#:eval contract-profile-eval #:preserve-source-locations
125111
(define/contract (sum* numbers)
126112
(-> (listof integer?) integer?)
@@ -139,4 +125,25 @@ arguments which specify their destination files. An argument of @racket[#f]
139125
(contract-profile (vector-max* (make-vector 10 (range (expt 10 7)))))
140126
]
141127

128+
}
129+
130+
@defproc[(contract-profile-thunk
131+
[thunk (-> any)]
132+
[#:module-graph-view-file module-graph-view-file (or/c path-string #f) #f]
133+
[#:boundary-view-file boundary-view-file (or/c path-string #f) #f]
134+
[#:boundary-view-key-file boundary-view-key-file (or/c path-string #f) #f]
135+
[#:report-space-efficient? report-space-efficient? any/c #f])
136+
any]{
137+
Like @racket[contract-profile], but as a function which takes a thunk to
138+
profile as argument.
139+
}
140+
141+
142+
@examples[#:eval contract-profile-eval #:preserve-source-locations
143+
144+
(contract-profile-thunk
145+
(lambda ()
146+
(sum* (range (expt 10 7)))))
147+
]
148+
142149
@(close-eval contract-profile-eval)

scribblings/eval-log.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#"")
1717
((contract-profile (sum* (range (expt 10 7))))
1818
((3) 0 () 0 () () (q values 49999995000000))
19-
#"Running time is 20.68% contracts\n529/2555 ms\n\n(-> (listof integer?) integer?) 528.5 ms\n#<blame>::-1 \n sum* 528.5 ms\n\n"
19+
#"Running time is 47.84% contracts\n1094/2287 ms\n\n(-> (listof integer?) integer?) 1094 ms\n#<blame>::-1 \n sum* 1094 ms\n\n"
2020
#"")
2121
((define/contract
2222
(vector-max* vec-of-numbers)
@@ -30,5 +30,9 @@
3030
#"")
3131
((contract-profile (vector-max* (make-vector 10 (range (expt 10 7)))))
3232
((3) 0 () 0 () () (q values 499999950000000))
33-
#"Running time is 93.25% contracts\n4453/4775 ms\n\n(-> (vectorof (listof any/c)) integer?) 2055.5 ms\n#<blame>::-1 \n vector-max* 2055.5 ms\n\n(-> (listof integer?) integer?) 2397 ms\n#<blame>::-1 \n sum* 2397 ms\n\n"
33+
#"Running time is 93.76% contracts\n4180/4458 ms\n\n(-> (vectorof (listof any/c)) integer?) 1939 ms\n#<blame>::-1 \n vector-max* 1939 ms\n\n(-> (listof integer?) integer?) 2241 ms\n#<blame>::-1 \n sum* 2241 ms\n\n"
34+
#"")
35+
((contract-profile-thunk (lambda () (sum* (range (expt 10 7)))))
36+
((3) 0 () 0 () () (q values 49999995000000))
37+
#"Running time is 44.16% contracts\n908/2056 ms\n\n(-> (listof integer?) integer?) 908 ms\n#<blame>::-1 \n sum* 908 ms\n\n"
3438
#"")

0 commit comments

Comments
 (0)