Clojure-Contrib

Contribs profiler can run into an Exception

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

The profile function from clojure.contrib.profile can run into
an Exception when it's argument is a lazy sequence.
Reproduce this problem:

(use 'clojure.contrib.profile)

(defn foo [x] (prof :foo (+ x 10)))

(profile (map foo (range 5))) ==>
java.lang.IllegalArgumentException: Wrong number of args passed to: core$max

(profile (pmap foo (range 5))) ==>
java.lang.IllegalArgumentException: Wrong number of args passed to: core$max

(profile (doseq [i (range 5)] (foo i))) ==> Works fine

Activity

Hide
Assembla Importer added a comment -

stu said: The problem isn't lazy sequences, but the absence of any data to report on. Commit 6dd033d9e12337f6630faa3d3f5c2e901a28c4f4 prevents the exception, and causes the printed report to be empty in the case there is nothing to report.

On the calling side, the examples shown above aren't profiling anything, because the lazy calls are never evaluated. You should use some kind of "do" form instead.

Show
Assembla Importer added a comment - stu said: The problem isn't lazy sequences, but the absence of any data to report on. Commit 6dd033d9e12337f6630faa3d3f5c2e901a28c4f4 prevents the exception, and causes the printed report to be empty in the case there is nothing to report. On the calling side, the examples shown above aren't profiling anything, because the lazy calls are never evaluated. You should use some kind of "do" form instead.
Hide
Assembla Importer added a comment -

stuart.sierra said: Updating tickets (#1, #2, #3, #4, #6, #20, #23, #25, #30, #31, #33, #34, #35, #37, #38, #52, #55, #58, #59, #60, #61, #62, #63, #64)

Show
Assembla Importer added a comment - stuart.sierra said: Updating tickets (#1, #2, #3, #4, #6, #20, #23, #25, #30, #31, #33, #34, #35, #37, #38, #52, #55, #58, #59, #60, #61, #62, #63, #64)
Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - Converted from http://www.assembla.com/spaces/clojure/tickets/31

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: