Fork me on GitHub
#reagent
<
2016-02-21
>
jrheard00:02:55

added some instrumentation, i see like 12 calls to do-render, each of which takes between 0.1ms and 1.86ms, which doesn't account for the 110ms-140ms that the forceUpdate call takes; will continue to dig

jrheard00:02:06

aha! found http://jasonrudolph.com/resources/201209-cljs-performance-profiling.png , which suggests adding console.profile() / console.profileEnd() calls

jrheard00:02:51

which gives me output like https://www.evernote.com/shard/s11/sh/bf71e155-af2b-47a3-b1cf-aced40ca39fd/ccc14883cdd4f1d2 , which suggests that one of my math-heavy functions is taking a nontrivial amount of time; i'll try memoizing it, it's pure

jrheard00:02:54

wow this profiling tool is useful

jrheard00:02:45

ha - perf is much smoother now, memoizing did the trick!

jrheard00:02:16

in unminified mode i'm seeing perf of 37-60ms

jrheard00:02:22

per hover/unhover event

jrheard00:02:53

anyway at this point this discussion is no longer reagent-specific and i'll shut up

jrheard00:02:09

console.profile() is my new best friend and i will use it constantly

jrheard00:02:10

thx all ❤️

gadfly36100:02:21

Hah i was listening!

gadfly36100:02:26

I might ping you offline about profiling sometime. Havent done that yet. Happy to hear memorizing helped a bit

jrheard00:02:25

minified mode ended up at 25ms-55ms, neato

jrheard00:02:30

❤️ pure functions

jrheard00:02:11

this was the entire code change necessary for the speedup: http://pastebin.com/Qhx9LxL3

jrheard00:02:57

hit me up re: profiling any time, if i get good at this (have done a lot of profiling in python, but none in JS) i'll eventually do a blog post (or more likely just accumulate a collection of other good blog posts other people have already written)

heeton02:02:48

Could someone please explain a simple point: if you specific an atom in a let block, why is that different to an external atom? Sorry if that’s badly explained… here’s a code example from the reagent docs - https://gist.github.com/heeton/465ca70602e39f6b3a6d

heeton02:02:29

If you define the atom outside of a component, all is good. If you want to define it inside a let block, it will display but not update.

heeton02:02:56

@gadfly361: ahhhhh, thank you!

gadfly36103:02:53

Np! Then after, be sure to read the best docs ever by mike thompson, which also covers this topic: https://github.com/Day8/re-frame/wiki/Creating-Reagent-Components#form-2--a-function-returning-a-function

heeton03:02:07

@gadfly361: As I understand it then: if the atom is defined in the let block, it’s being redefined upon every single rendering of the component, and so can never be updated?

gadfly36103:02:39

Thats correct - if you dont add the inner functions

heeton03:02:48

Awesome. Thanks simple_smile

heeton03:02:57

(pieces slowly clicking into place…)

gadfly36103:02:04

By adding the inner function, then the let atom can persist between re-renders

heeton03:02:52

@gadfly361: Well spin my nipple nuts and send me to Alaska. It works!

heeton03:02:58

Thanks again simple_smile

gadfly36103:02:29

Haha glad it worked!