Free as in Freedom: Codeberg.org. Create your repos and join us!
Join Donate
Browse Source

Start profiling via cpuprofiler crate.

Jan Walter 1 year ago
parent
commit
d8028d80cb
4 changed files with 78 additions and 0 deletions
  1. 73
    0
      Cargo.lock
  2. 1
    0
      Cargo.toml
  3. BIN
      profile/recursive_build.profile.gz
  4. 4
    0
      src/lib.rs

+ 73
- 0
Cargo.lock View File

@@ -2,6 +2,7 @@
2 2
 name = "pbrt"
3 3
 version = "0.2.2"
4 4
 dependencies = [
5
+ "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
5 6
  "crossbeam 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
6 7
  "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
7 8
  "image 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -17,6 +18,29 @@ name = "adler32"
17 18
 version = "1.0.0"
18 19
 source = "registry+https://github.com/rust-lang/crates.io-index"
19 20
 
21
+[[package]]
22
+name = "backtrace"
23
+version = "0.2.3"
24
+source = "registry+https://github.com/rust-lang/crates.io-index"
25
+dependencies = [
26
+ "backtrace-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
27
+ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
28
+ "dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
29
+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
30
+ "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
31
+ "rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
32
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
33
+]
34
+
35
+[[package]]
36
+name = "backtrace-sys"
37
+version = "0.1.14"
38
+source = "registry+https://github.com/rust-lang/crates.io-index"
39
+dependencies = [
40
+ "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
41
+ "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
42
+]
43
+
20 44
 [[package]]
21 45
 name = "bitflags"
22 46
 version = "0.9.1"
@@ -27,16 +51,44 @@ name = "byteorder"
27 51
 version = "1.0.0"
28 52
 source = "registry+https://github.com/rust-lang/crates.io-index"
29 53
 
54
+[[package]]
55
+name = "cc"
56
+version = "1.0.0"
57
+source = "registry+https://github.com/rust-lang/crates.io-index"
58
+
59
+[[package]]
60
+name = "cfg-if"
61
+version = "0.1.2"
62
+source = "registry+https://github.com/rust-lang/crates.io-index"
63
+
30 64
 [[package]]
31 65
 name = "color_quant"
32 66
 version = "1.0.0"
33 67
 source = "registry+https://github.com/rust-lang/crates.io-index"
34 68
 
69
+[[package]]
70
+name = "cpuprofiler"
71
+version = "0.0.3"
72
+source = "registry+https://github.com/rust-lang/crates.io-index"
73
+dependencies = [
74
+ "error-chain 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
75
+ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
76
+]
77
+
35 78
 [[package]]
36 79
 name = "crossbeam"
37 80
 version = "0.3.0"
38 81
 source = "registry+https://github.com/rust-lang/crates.io-index"
39 82
 
83
+[[package]]
84
+name = "dbghelp-sys"
85
+version = "0.2.0"
86
+source = "registry+https://github.com/rust-lang/crates.io-index"
87
+dependencies = [
88
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
89
+ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
90
+]
91
+
40 92
 [[package]]
41 93
 name = "deflate"
42 94
 version = "0.7.9"
@@ -59,6 +111,14 @@ dependencies = [
59 111
  "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
60 112
 ]
61 113
 
114
+[[package]]
115
+name = "error-chain"
116
+version = "0.5.0"
117
+source = "registry+https://github.com/rust-lang/crates.io-index"
118
+dependencies = [
119
+ "backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
120
+]
121
+
62 122
 [[package]]
63 123
 name = "getopts"
64 124
 version = "0.2.14"
@@ -276,6 +336,11 @@ name = "redox_syscall"
276 336
 version = "0.1.31"
277 337
 source = "registry+https://github.com/rust-lang/crates.io-index"
278 338
 
339
+[[package]]
340
+name = "rustc-demangle"
341
+version = "0.1.5"
342
+source = "registry+https://github.com/rust-lang/crates.io-index"
343
+
279 344
 [[package]]
280 345
 name = "rustc-serialize"
281 346
 version = "0.3.22"
@@ -323,13 +388,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
323 388
 
324 389
 [metadata]
325 390
 "checksum adler32 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff33fe13a08dbce05bcefa2c68eea4844941437e33d6f808240b54d7157b9cd"
391
+"checksum backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "346d7644f0b5f9bc73082d3b2236b69a05fd35cce0cfa3724e184e6a5c9e2a2f"
392
+"checksum backtrace-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "c63ea141ef8fdb10409d0f5daf30ac51f84ef43bff66f16627773d2a292cd189"
326 393
 "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
327 394
 "checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
395
+"checksum cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7db2f146208d7e0fbee761b09cd65a7f51ccc38705d4e7262dad4d73b12a76b1"
396
+"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
328 397
 "checksum color_quant 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a475fc4af42d83d28adf72968d9bcfaf035a1a9381642d8e85d8a04957767b0d"
398
+"checksum cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "33f07976bb6821459632d7a18d97ccca005cb5c552f251f822c7c1781c1d7035"
329 399
 "checksum crossbeam 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8837ab96533202c5b610ed44bc7f4183e7957c1c8f56e8cc78bb098593c8ba0a"
400
+"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
330 401
 "checksum deflate 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "464225978f3f01068194aa948852ec121d179c3f874d499d74c432953bf1917b"
331 402
 "checksum deque 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a694dae478589798d752c7125542f8a5ae8b6e59476172baf2eed67357bdfa27"
332 403
 "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180"
404
+"checksum error-chain 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd5c82c815138e278b8dcdeffc49f27ea6ffb528403e9dea4194f2e3dd40b143"
333 405
 "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685"
334 406
 "checksum gif 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8a80d6fe9e52f637df9afd4779449a7be17c39cc9c35b01589bb833f956ba596"
335 407
 "checksum image 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "634700d4a51fa91ceaa798001d46bf862c7b712bd691085d7ba6afd5521e21f7"
@@ -356,6 +428,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
356 428
 "checksum rayon 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c83adcb08e5b922e804fe1918142b422602ef11f2fd670b0b52218cb5984a20"
357 429
 "checksum rayon-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "767d91bacddf07d442fe39257bf04fd95897d1c47c545d009f6beb03efd038f8"
358 430
 "checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509"
431
+"checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e"
359 432
 "checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b"
360 433
 "checksum scoped_threadpool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3ef399c8893e8cb7aa9696e895427fab3a6bf265977bb96e126f24ddd2cda85a"
361 434
 "checksum syn 0.10.8 (registry+https://github.com/rust-lang/crates.io-index)" = "58fd09df59565db3399efbba34ba8a2fec1307511ebd245d0061ff9d42691673"

+ 1
- 0
Cargo.toml View File

@@ -13,3 +13,4 @@ getopts="0.2"
13 13
 pest = "^1.0.0-beta"
14 14
 pest_derive = "^1.0.0-beta"
15 15
 pbr = "1.0"
16
+cpuprofiler = "0.0.3"

BIN
profile/recursive_build.profile.gz View File


+ 4
- 0
src/lib.rs View File

@@ -864,6 +864,7 @@ extern crate image;
864 864
 extern crate crossbeam;
865 865
 extern crate pbr;
866 866
 // extern crate openexr;
867
+extern crate cpuprofiler;
867 868
 
868 869
 // use std::cell::RefCell;
869 870
 use std::borrow::Borrow;
@@ -881,6 +882,7 @@ use std::sync::mpsc;
881 882
 use num::Zero;
882 883
 use image::{ImageResult, DynamicImage};
883 884
 // use openexr::{FrameBuffer, Header, PixelType, ScanlineOutputFile};
885
+use cpuprofiler::PROFILER;
884 886
 
885 887
 pub type Float = f32;
886 888
 
@@ -6746,6 +6748,7 @@ impl BVHAccel {
6746 6748
         // TODO: if (splitMethod == SplitMethod::HLBVH)
6747 6749
         let mut total_nodes: usize = 0;
6748 6750
         let mut ordered_prims: Vec<Arc<Primitive + Sync + Send>> = Vec::with_capacity(num_prims);
6751
+        PROFILER.lock().unwrap().start("./recursive_build.profile").unwrap();
6749 6752
         let root = BVHAccel::recursive_build(bvh.clone(), // instead of self
6750 6753
                                              // arena,
6751 6754
                                              &mut primitive_info,
@@ -6753,6 +6756,7 @@ impl BVHAccel {
6753 6756
                                              num_prims,
6754 6757
                                              &mut total_nodes,
6755 6758
                                              &mut ordered_prims);
6759
+        PROFILER.lock().unwrap().stop().unwrap();
6756 6760
         // flatten first
6757 6761
         let mut nodes = vec![LinearBVHNode::default(); total_nodes];
6758 6762
         let mut offset: usize = 0;

Loading…
Cancel
Save