diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-26 09:13:09 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-26 09:13:09 +0100 |
commit | fc0f4ed6353174eb80229571e3e54993b1605e41 (patch) | |
tree | 53bfceb17b0d730490e8f489c0c0611433de46e5 | |
parent | 0129790a8f84a0858abcb1448e1052caa01fc41c (diff) | |
parent | d621533f15871ce233e3a1dcc0fb10a631090678 (diff) |
Merge #1442
1442: add cpuprofile to ra_prof r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r-- | Cargo.lock | 52 | ||||
-rw-r--r-- | crates/ra_batch/Cargo.toml | 4 | ||||
-rw-r--r-- | crates/ra_prof/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_prof/src/lib.rs | 33 |
4 files changed, 90 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock index 1465268b2..4f3538a51 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -41,6 +41,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
41 | 41 | ||
42 | [[package]] | 42 | [[package]] |
43 | name = "backtrace" | 43 | name = "backtrace" |
44 | version = "0.2.3" | ||
45 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
46 | dependencies = [ | ||
47 | "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", | ||
48 | "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
49 | "dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
50 | "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
51 | "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", | ||
52 | "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", | ||
53 | "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
54 | ] | ||
55 | |||
56 | [[package]] | ||
57 | name = "backtrace" | ||
44 | version = "0.3.30" | 58 | version = "0.3.30" |
45 | source = "registry+https://github.com/rust-lang/crates.io-index" | 59 | source = "registry+https://github.com/rust-lang/crates.io-index" |
46 | dependencies = [ | 60 | dependencies = [ |
@@ -264,6 +278,15 @@ dependencies = [ | |||
264 | ] | 278 | ] |
265 | 279 | ||
266 | [[package]] | 280 | [[package]] |
281 | name = "cpuprofiler" | ||
282 | version = "0.0.3" | ||
283 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
284 | dependencies = [ | ||
285 | "error-chain 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
286 | "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", | ||
287 | ] | ||
288 | |||
289 | [[package]] | ||
267 | name = "crossbeam-channel" | 290 | name = "crossbeam-channel" |
268 | version = "0.3.8" | 291 | version = "0.3.8" |
269 | source = "registry+https://github.com/rust-lang/crates.io-index" | 292 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -312,6 +335,15 @@ dependencies = [ | |||
312 | ] | 335 | ] |
313 | 336 | ||
314 | [[package]] | 337 | [[package]] |
338 | name = "dbghelp-sys" | ||
339 | version = "0.2.0" | ||
340 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
341 | dependencies = [ | ||
342 | "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
343 | "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
344 | ] | ||
345 | |||
346 | [[package]] | ||
315 | name = "derive-new" | 347 | name = "derive-new" |
316 | version = "0.5.6" | 348 | version = "0.5.6" |
317 | source = "registry+https://github.com/rust-lang/crates.io-index" | 349 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -377,6 +409,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
377 | 409 | ||
378 | [[package]] | 410 | [[package]] |
379 | name = "error-chain" | 411 | name = "error-chain" |
412 | version = "0.5.0" | ||
413 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
414 | dependencies = [ | ||
415 | "backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
416 | ] | ||
417 | |||
418 | [[package]] | ||
419 | name = "error-chain" | ||
380 | version = "0.12.1" | 420 | version = "0.12.1" |
381 | source = "registry+https://github.com/rust-lang/crates.io-index" | 421 | source = "registry+https://github.com/rust-lang/crates.io-index" |
382 | dependencies = [ | 422 | dependencies = [ |
@@ -672,6 +712,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
672 | 712 | ||
673 | [[package]] | 713 | [[package]] |
674 | name = "lazy_static" | 714 | name = "lazy_static" |
715 | version = "0.2.11" | ||
716 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
717 | |||
718 | [[package]] | ||
719 | name = "lazy_static" | ||
675 | version = "1.3.0" | 720 | version = "1.3.0" |
676 | source = "registry+https://github.com/rust-lang/crates.io-index" | 721 | source = "registry+https://github.com/rust-lang/crates.io-index" |
677 | 722 | ||
@@ -1024,6 +1069,7 @@ dependencies = [ | |||
1024 | "ra_db 0.1.0", | 1069 | "ra_db 0.1.0", |
1025 | "ra_hir 0.1.0", | 1070 | "ra_hir 0.1.0", |
1026 | "ra_ide_api 0.1.0", | 1071 | "ra_ide_api 0.1.0", |
1072 | "ra_prof 0.1.0", | ||
1027 | "ra_project_model 0.1.0", | 1073 | "ra_project_model 0.1.0", |
1028 | "ra_syntax 0.1.0", | 1074 | "ra_syntax 0.1.0", |
1029 | "ra_vfs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1075 | "ra_vfs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1176,6 +1222,7 @@ name = "ra_prof" | |||
1176 | version = "0.1.0" | 1222 | version = "0.1.0" |
1177 | dependencies = [ | 1223 | dependencies = [ |
1178 | "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", | 1224 | "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", |
1225 | "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1179 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1226 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1180 | "once_cell 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1227 | "once_cell 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1181 | ] | 1228 | ] |
@@ -1987,6 +2034,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1987 | "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" | 2034 | "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" |
1988 | "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" | 2035 | "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" |
1989 | "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" | 2036 | "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" |
2037 | "checksum backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "346d7644f0b5f9bc73082d3b2236b69a05fd35cce0cfa3724e184e6a5c9e2a2f" | ||
1990 | "checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" | 2038 | "checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" |
1991 | "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" | 2039 | "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" |
1992 | "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" | 2040 | "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" |
@@ -2012,11 +2060,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2012 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" | 2060 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" |
2013 | "checksum colosseum 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "370c83b49aedf022ee27942e8ae1d9de1cf40dc9653ee6550e4455d08f6406f9" | 2061 | "checksum colosseum 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "370c83b49aedf022ee27942e8ae1d9de1cf40dc9653ee6550e4455d08f6406f9" |
2014 | "checksum console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ca57c2c14b8a2bf3105bc9d15574aad80babf6a9c44b1058034cdf8bd169628" | 2062 | "checksum console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ca57c2c14b8a2bf3105bc9d15574aad80babf6a9c44b1058034cdf8bd169628" |
2063 | "checksum cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "33f07976bb6821459632d7a18d97ccca005cb5c552f251f822c7c1781c1d7035" | ||
2015 | "checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" | 2064 | "checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" |
2016 | "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" | 2065 | "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" |
2017 | "checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" | 2066 | "checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" |
2018 | "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" | 2067 | "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" |
2019 | "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" | 2068 | "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" |
2069 | "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" | ||
2020 | "checksum derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6ca414e896ae072546f4d789f452daaecf60ddee4c9df5dc6d5936d769e3d87c" | 2070 | "checksum derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6ca414e896ae072546f4d789f452daaecf60ddee4c9df5dc6d5936d769e3d87c" |
2021 | "checksum deunicode 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" | 2071 | "checksum deunicode 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" |
2022 | "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" | 2072 | "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" |
@@ -2028,6 +2078,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2028 | "checksum ena 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3dc01d68e08ca384955a3aeba9217102ca1aa85b6e168639bf27739f1d749d87" | 2078 | "checksum ena 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3dc01d68e08ca384955a3aeba9217102ca1aa85b6e168639bf27739f1d749d87" |
2029 | "checksum encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" | 2079 | "checksum encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" |
2030 | "checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" | 2080 | "checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" |
2081 | "checksum error-chain 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd5c82c815138e278b8dcdeffc49f27ea6ffb528403e9dea4194f2e3dd40b143" | ||
2031 | "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" | 2082 | "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" |
2032 | "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" | 2083 | "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" |
2033 | "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" | 2084 | "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" |
@@ -2062,6 +2113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2062 | "checksum join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc7a5290e8c2606ce2be49f456d50f69173cb96d1541e4f66e34ac8b331a98f" | 2113 | "checksum join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc7a5290e8c2606ce2be49f456d50f69173cb96d1541e4f66e34ac8b331a98f" |
2063 | "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" | 2114 | "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" |
2064 | "checksum lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cc4fd87be4a815fd373e02773983940f0d75fb26fde8c098e9e45f7af03154c0" | 2115 | "checksum lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cc4fd87be4a815fd373e02773983940f0d75fb26fde8c098e9e45f7af03154c0" |
2116 | "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" | ||
2065 | "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" | 2117 | "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" |
2066 | "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" | 2118 | "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" |
2067 | "checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" | 2119 | "checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" |
diff --git a/crates/ra_batch/Cargo.toml b/crates/ra_batch/Cargo.toml index 7d8837fc3..f521937c5 100644 --- a/crates/ra_batch/Cargo.toml +++ b/crates/ra_batch/Cargo.toml | |||
@@ -15,5 +15,9 @@ ra_ide_api = { path = "../ra_ide_api" } | |||
15 | ra_hir = { path = "../ra_hir" } | 15 | ra_hir = { path = "../ra_hir" } |
16 | ra_project_model = { path = "../ra_project_model" } | 16 | ra_project_model = { path = "../ra_project_model" } |
17 | 17 | ||
18 | [dependencies.ra_prof] | ||
19 | path = "../ra_prof" | ||
20 | # features = [ "cpuprofiler" ] | ||
21 | |||
18 | [dev-dependencies] | 22 | [dev-dependencies] |
19 | test_utils = { path = "../test_utils" } | 23 | test_utils = { path = "../test_utils" } |
diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml index d55af18f5..787e18385 100644 --- a/crates/ra_prof/Cargo.toml +++ b/crates/ra_prof/Cargo.toml | |||
@@ -9,3 +9,4 @@ publish = false | |||
9 | once_cell = "0.2.0" | 9 | once_cell = "0.2.0" |
10 | itertools = "0.8.0" | 10 | itertools = "0.8.0" |
11 | backtrace = "0.3.28" | 11 | backtrace = "0.3.28" |
12 | cpuprofiler = { version = "0.0.3", optional = true } | ||
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index de67b4031..1e8d780ab 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs | |||
@@ -255,6 +255,39 @@ impl Drop for Scope { | |||
255 | } | 255 | } |
256 | } | 256 | } |
257 | 257 | ||
258 | /// A wrapper around https://github.com/AtheMathmo/cpuprofiler | ||
259 | /// | ||
260 | /// It can be used to capture sampling profiles of sections of code. | ||
261 | /// It is not exactly out-of-the-box, as it relies on gperftools. | ||
262 | /// See the docs for the crate for more! | ||
263 | #[derive(Debug)] | ||
264 | pub struct CpuProfiler { | ||
265 | _private: (), | ||
266 | } | ||
267 | |||
268 | pub fn cpu_profiler() -> CpuProfiler { | ||
269 | #[cfg(feature = "cpuprofiler")] | ||
270 | { | ||
271 | cpuprofiler::PROFILER.lock().unwrap().start("./out.profile").unwrap(); | ||
272 | } | ||
273 | |||
274 | #[cfg(not(feature = "cpuprofiler"))] | ||
275 | { | ||
276 | eprintln!("cpuprofiler feature is disabled") | ||
277 | } | ||
278 | |||
279 | CpuProfiler { _private: () } | ||
280 | } | ||
281 | |||
282 | impl Drop for CpuProfiler { | ||
283 | fn drop(&mut self) { | ||
284 | #[cfg(feature = "cpuprofiler")] | ||
285 | { | ||
286 | cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | |||
258 | #[cfg(test)] | 291 | #[cfg(test)] |
259 | mod tests { | 292 | mod tests { |
260 | use super::*; | 293 | use super::*; |