Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using React's Perf tools to profile rum apps #74

Closed
lynaghk opened this issue Jun 11, 2016 · 3 comments
Closed

Using React's Perf tools to profile rum apps #74

lynaghk opened this issue Jun 11, 2016 · 3 comments

Comments

@lynaghk
Copy link
Contributor

lynaghk commented Jun 11, 2016

It took me a while to figure out how to get React's Perf tools working within ClojureScript, and I think it'd be helpful for others to have a section in the Rum README.
I've enclosed a draft below.

I'm not sure the best way to configure Leiningen / cljsbuild / figwheel to keep the Perf tools only in development builds (or if they'll get advanced-optimizationed away) --- I bet it could be done with Leiningen's project.clj :profiles key, but there may be a better way.
I'd love if someone could chime in on that.

## Profiling

To use [React.js Perf tools](https://facebook.github.io/react/docs/perf.html) from Rum, specify the `react-with-addons` dependency in your `project.clj`, making sure to exclude any transitive react dependencies:

```clj
[rum "0.9.0" :exclusions [cljsjs/react cljsjs/react-dom]]
[cljsjs/react-dom "15.1.0-0" :exclusions [cljsjs/react]]
[cljsjs/react-dom-server "15.1.0-0" :exclusions [cljsjs/react]]
[cljsjs/react-with-addons "15.1.0-0"]
```

Then from within your program run:

```clj
(js/React.addons.Perf.start)
;;run your app
(js/React.addons.Perf.stop)
(js/React.addons.Perf.printWasted)
```

and results will be printed to the developer console.
@piranha
Copy link
Collaborator

piranha commented Jun 11, 2016

or if they'll get advanced-optimizationed away

I bet they won't be - Closure Compiler does not optimize :foreign-libs, which is how everybody uses React. It seems to me profiles are the best way to handle that.

@rauhs
Copy link
Contributor

rauhs commented Jun 11, 2016

I think this would be great for the wiki. I just created a wiki for rum and added some useful links: https://github.com/tonsky/rum/wiki

@tonsky
Copy link
Owner

tonsky commented Jun 19, 2016

Moved to wiki

@tonsky tonsky closed this as completed Jun 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants