Fork me on GitHub
#clojurescript
<
2016-11-09
>
sophiago00:11:03

@dnolen a little late, but re: my question about profiling...the code i'm comparing uses createFactory rather abusively and the generating functions aren't identical, map vs. for loop not a great comparison, but the fwiw the om version is actually lagging behind the further i push it whereas the js one seems bound to 40% cpu usage. again, i'd just chalk that up to the functions employed and say i greatly prefer the simplicity. but i guess it shows i was always managing the react lifecycle well, plus good thing i didn't try to sell that client based on benchmarks (i seem sold anyway) since i may have had to hack through tons of things manually to beat what he had that way. although he wasn't using any comparable framework previously so perhaps not. anyway, grain of salt... but seems to back up what you told me

jcb08:11:10

simple question - how to I swap a css selector value programatically in cljs?

jcb08:11:28

directly without an atom

rauh08:11:17

@jcb Can you make an example? A css selector selects DOM elements...

jcb08:11:53

I just need to set some css to already rendered reagent components

jcb08:11:38

I'm used to clojure just not the frontend

jrheard09:11:34

@jcb - i think js/document.querySelector is a thing, or may js/document.querySelectorAll, google until you fin dosmething that looks like that

jrheard09:11:43

play with the .-style attribute of the objects it returns

jrheard09:11:46

that should give you what you want

jrheard09:11:12

what you are describing is a bit unusual though - usually you’d want to epxress your components’ css using reagent

jcb09:11:23

thanks .-style is returning null

jrheard09:11:25

but if you have a specific reason why you want to do this, i think that that function is what i’d reach for

jrheard09:11:39

try console.logging the output of calling that function i mentioned

jrheard09:11:47

you should be able to expand it and inspect it with a good UI

jrheard09:11:28

hm maybe not

jrheard09:11:40

sorry, it’s late and i’m on pain meds 😕

jrheard09:11:05

hm, (js/console.log (.-style (js/document.querySelector “canvas”))) works fine if i paste it into one of the snippet boxes on http://blog.jrheard.com/procedural-dungeon-generation-drunkards-walk-in-clojurescript

jcb09:11:10

It's to get around an odd z-index problem with a frontend that has been written by someone else

jrheard09:11:33

you should be able to manipulate this style object with aget and aset, if memory serves

jcb09:11:55

thanks jrheard!

jrheard09:11:51

(aset (.-style (js/document.querySelector "canvas")) "background-color" “pink”) seems to work well, for instnace

cfleming12:11:12

So I’m pretty much a total CLJS newb, and I’m having problems pretty printing an object in Node on AWS lambda.

cfleming12:11:43

I’m trying to print the environment variables out, so I’m doing this: (println (pr-str (js->clj (.. js/process -env))))

cfleming12:11:04

This just results in #object[Object [object Object]], and I can’t figure out why.

cfleming12:11:15

Similarly, (get (js->clj (.. js/process -env)) "AWS_ACCESS_KEY_ID”) results in nil, but (aget (.. js/process -env) "AWS_ACCESS_KEY_ID”) produces the value I want.

cfleming12:11:31

What am I missing?

thheller12:11:46

@cfleming I know nothing about AWS but most likely js/process.env is not a normal javascript object but something else which js->clj does not support

cfleming12:11:16

@thheller That might explain it, thanks.

rauh12:11:34

Never used node myself. But note the comment.

cfleming12:11:58

@rauh: I see, that’s interesting, thanks. That looks like the problem.

cfleming12:11:09

Kind of awful solution.

thheller12:11:13

hehe I cringed when I saw the solution 😛

cfleming12:11:50

Right now, if it works it’s good enough for me 🙂

thheller13:11:06

if the object is shallow you can probably (-> js/process.env (js/goog.object.clone) (js->clj))

cfleming13:11:06

I think I’ll just aget it right now, and write to the author of cljs-lambda to ask about it.

thheller13:11:41

js/goog.object.get is the preferred getter

thheller13:11:55

aget is meant to arrays and you are not working with an array

thheller13:11:07

might break in the future (though) unlikely

cfleming13:11:13

Oh, ok, thanks.

cfleming13:11:15

I’ll do that.

rovanion15:11:58

Long shot: Has anyone used multiple textures with http://thi.ng geom?

darwin17:11:18

have an interesting issue with :advanced mode build: https://gist.github.com/darwin/34b2eaf97f1823b1180eb14ad64af9fd initial-config is not used so it should be elided, 01 does not elide it, 02 does note the comment there

darwin17:11:19

it looks like I’m hitting some arbitrary limit on how deep closure compiler goes analysing my code, but this depth is pretty shallow IMO

dnolen17:11:47

@darwin that’s interesting but this probably a better conversation for #cljs-dev

darwin17:11:06

ok, will continue there

wielderofmjolnir19:11:16

Is it possible to access the current compiler profile, so as to use one app-state for dev and another for prod?

dnolen19:11:31

@wielderofmjolnir this can be done via a macro

dnolen19:11:43

macros can see the compiler environment via &env

wielderofmjolnir19:11:16

Oh, sweet! Thanks!

mfikes20:11:11

Check Lumo ^ out. It is really as good as it looks. 🙂

dnolen20:11:36

Cool stuff

kenny20:11:35

In order to get consistent performance benchmarks, does it make sense to run the code you are trying to benchmark in several tabs (say 100) then aggregate the time results once all the tabs have finished running the code? Obviously I would prefer to not have 100 tabs open and close, is there a better way to run cljs code (targeting the browser) many times in an isolated environment?

dnolen20:11:34

@kenny running multiple benchmarks in multiple tabs is probably not a good idea

dnolen20:11:39

you generally want to run one benchmark at a time

dnolen21:11:14

if you’re serious about benchmarking you also want to make sure you’re not running anything else but the benchmark

kenny21:11:49

So you're saying the better solution would be to run it 100 times in 1 tab?

dnolen21:11:01

absolutely

dnolen21:11:06

benchmarking is a painful slow process

dnolen21:11:07

but it also depends on what you’re trying to achieve

kenny21:11:23

Will the results across all tabs really be so biased that it is not worth using?

dnolen21:11:36

browsers are multiprocess

dnolen21:11:45

unfocused tabs get penalized

dnolen21:11:49

you are subject to OS scheduling

cschep21:11:17

plus your benchmark would be “how fast does this code run… while being also run 99 other times."

cschep21:11:22

don’t you want to know “how fast does this code run?"

kenny21:11:58

In this case, I am really just looking for relative performance, not absolute. So, if all tabs are unfocused would they get penalized in an equal amount, making the results consistent but inaccurate?

dnolen21:11:58

@kenny I just do not recommend what you are suggesting

dnolen21:11:02

it won’t tell you anything interesting

dnolen21:11:15

if you want to know anything at all - run them in a focused tab, one after the other

dnolen21:11:21

if it’s not browser specific - just run it against Node or even better an unadorned JS VM like JavaScriptCore

dnolen21:11:30

if you’re not looking for particularly accurate results - then no the methodology doesn’t matter - but I wouldn’t put any real trust in whatever information you collect

kenny21:11:13

You wouldn't trust the results if the benchmark was ran in the same way and then compared? It seems like the consistency is trustworthy (if it is consistent)

jrheard21:11:20

@kenny i use https://github.com/ptaoussanis/tufte for relative benchmarking fwiw

cschep21:11:27

you don’t seem to want the answer to the question you asked 🙂

kenny21:11:56

Well, I guess that is part of the question 🙂

kenny21:11:15

If there is no consistency then of course you can't trust the results

jrheard21:11:19

when optimizing a fucntion, i just run the function under test like 250 times or whatever, in one tab, and then make a change and then run it again in the same way

jrheard21:11:24

seems to work fine

jrheard21:11:49

if i see too much variation then i bump up the number of times i run it and that usually solves the problem

jrheard21:11:52

i am.. not a scientist

kenny21:11:47

@jrheard Right. That normally works great. Also, thanks for the Tufte suggestion. I will take a look at it 🙂 The only problem with that method is when you are not testing pure functions (`memoize`ed functions).

jrheard21:11:55

ah interesting

dnolen21:11:11

@kenny no I would not trust the results

jrheard21:11:19

if it’s a function you control, perhaps you could add a flag that turns off memoization?

jrheard21:11:25

just briefly while you’re poking at it

dnolen21:11:31

I’ve done too much benchmarking around ClojureScript to believe anything that doesn’t follow the procedures I outlined above

cschep21:11:39

there is just so much that can be going on with with the browser and the OS and threads and scheduling and stuff right? you’d have to be an expert at so many things to know what you could count on and what is random system jitter and how many threads make your machine start to spend a ton of time worrying about overhead vs. running your tests

kenny21:11:27

@dnolen @cschep @jrheard thanks for the input! 🙂 I will change the direction I was headed down.

cschep21:11:43

good luck I’m sure you’ll find some good data

jrheard21:11:57

profiling/optimizing is super fun

jrheard21:11:00

lots of immediate gratification

kenny21:11:10

"immediate"

noisesmith21:11:33

@cschep fancy seeing you here

cschep22:11:10

@noisesmith hey man! long time!