This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-10
Channels
- # announcements (2)
- # beginners (37)
- # boot (1)
- # cider (76)
- # clara (14)
- # cljs-dev (132)
- # cljsjs (1)
- # cljsrn (2)
- # clojure (18)
- # clojure-colombia (5)
- # clojure-finland (1)
- # clojure-hamburg (1)
- # clojure-italy (2)
- # clojure-nl (8)
- # clojure-russia (1)
- # clojure-spec (28)
- # clojure-uk (85)
- # clojurescript (84)
- # code-reviews (25)
- # cursive (10)
- # data-science (3)
- # datomic (30)
- # editors (1)
- # emacs (3)
- # fulcro (106)
- # graphql (4)
- # hyperfiddle (26)
- # jobs (2)
- # jobs-discuss (124)
- # keechma (3)
- # leiningen (1)
- # lumo (6)
- # off-topic (5)
- # other-lisps (5)
- # reagent (5)
- # ring-swagger (4)
- # shadow-cljs (140)
- # spacemacs (22)
- # specter (2)
- # sql (48)
- # tools-deps (78)
- # vim (7)
"If you already know what recursion is, just remember the answer. Otherwise, find someone who is standing closer to Douglas Hofstadter than you are; then ask him or her what recursion is."
Hello all, is there any way having a number and verify some issues and stop flow if having problems, like in -> ?
-> stock, verify with quantity of sales order, descrease stock, add quantity to sales order
, if there is no stock, stop the main stream to be processed?
some->
... then if any part returns nil
the whole pipeline stops.
This one has been in the back of my mind for quite a while... How does one test code dealing with timeouts quickly? Mock timers/clocks that tick faster or is there something better?
100ms is an eternity to the CPU
Precisely my doubt
https://github.com/ReactiveX/rxjs/blob/master/doc/marble-testing.md I found this but seems hacky, and not really data centric
The code works, but takes about a second to solve for the 7 element vector, which is very poor compared to a similar solution in Java.
@UC2B7D28Y are you perhaps including jvm/clj startup time in that one-second figure?
@U077BEWNQ I am timing it using the (time) method just before calling the minimumSwaps() .. I need to figure out how 'time' calcs its elapsed time
Shouldn't be including startup time, then. I suspect something's weird with your setup, mfikes' time seems much more what I would expect.
So, I was able to marginally optimize it, by using 'drop' (which returns a lazy sequence) over 'subvec' (returns a persistent vector).. I should maybe check my setup too.
My recommendation is to not even think about optimizing the code until you solve the setup problems. I just ran it in the REPL I happened to have open, & similar results to Mike:
user> (time (println (minimumSwaps [7 6 5 4 3 2 1])))
3
"Elapsed time: 1.254905 msecs"
nil
This isn't an issue with unoptimized code unless you're running on a box that's more than 15 years old ๐
Maybe tell us how exactly you're loading and running it? Is this in a command-line clojure REPL? Or in some editor? Give us the details of your setup ๐
(also feel free to move it back to the main #beginners thread if you'd prefer; if nothing else, you might get faster responses)
Thanks for the quick response @U077BEWNQ.. I am uploading my answers to HackerRank and the inputs on hacker rank have vector sizes of 100K & upwards. My performance problems are for larger data sets.
I also ran it in Spacemacs/CIDER. Something's definitely not right with your setup.
OK, @U077BEWNQ ill check out a few things on my end
@U077BEWNQ Ill move my question to the beginner thread. I implemented a similar solution in java and it performs better than the clojure code.. I wonder how I can optimize my coljure solution..
If it were me, I'd probably start by calling htop
or top
. I wonder if you've somehow got a bunch of orphaned JVM processes out there. I'd follow that with an emacs restart, and if that didn't work, a system reboot. Those three between them should identify or rule out the most likely problems.
That said, I definitely hear that your broader question is about how to optimize the code, not about why it takes a full second to run, so I'll leave it at that.
@U077BEWNQ - Thanks for the tips, trying them out now.
I tried using transients, but has an open bug for subvec, that I am using in my solution- https://dev.clojure.org/jira/browse/CLJ-787
@jaihindh.reddy I think tea-time might be helpful?