Clojure contrib profiler error

82 views
Skip to first unread message

Adrian Mowat

unread,
Aug 4, 2012, 7:22:41 AM8/4/12
to clo...@googlegroups.com
Hi All

I'm trying to run the clojure contrib profiler and I'm getting an error.  Has anyone faced the same problem?

user=> (use 'clojure.contrib.profile)
nil
user=> (defn my-function [x y]
                (let [sum (prof :addition (+ x y))
                      product (prof :multiplication (* x y))]
                  [sum product]))
#'user/my-function
user=> (profile (dotimes [i 10000] (my-function 3 4)))
IllegalStateException Can't dynamically bind non-dynamic var: clojure.contrib.profile/*profile-data*  clojure.lang.Var.pushThreadBindings (Var.java:353)

user=> *enable-profiling*
true



my project.clj looks like this

(defproject clam "0.1.0-SNAPSHOT"
  :description "Data description language for parsing text streams"
  :license {:name "MIT Licence"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.clojure/clojure-contrib "1.2.0"]
                 [midje "1.4.0"]
                 [com.stuartsierra/lazytest "1.2.3"]]
  :repositories {"stuart" "http://stuartsierra.com/maven2"})


Thanks very much


Adrian

Jonathan Fischer Friberg

unread,
Aug 4, 2012, 10:09:51 AM8/4/12
to clo...@googlegroups.com
clojure.contrib is not supported in clojure versions 1.3+
The reason in this case is that in 1.3+, it is necessary to add ^:dynamic or ^{:dynamic true} in the def form (i.e. to the metadata)
for the var to be dynamically changed with bindings.

Fixed clojure.contrib.profile:
https://gist.github.com/3257930

Jonathan
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

Softaddicts

unread,
Aug 4, 2012, 10:30:20 AM8/4/12
to clo...@googlegroups.com
You are running clojure 1.3 or greater with the pre-1.3 contrib.

Since 1.3, contrib has been split in separate libs, you can find where the
different parts have moved here;

http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

The profiling stuff did not make it it seems. A java profiler would be your best bet.

There is a 1.3 compatible monolithic contrib out there but I would not bundle it
as a standard dependency. The new libs are moving forward faster now that they
can be delivered individually.

Luc
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
--
Softaddicts<lprefo...@softaddicts.ca> sent by ibisMail from my ipad!

Peter Taoussanis

unread,
Aug 6, 2012, 5:08:19 AM8/6/12
to clo...@googlegroups.com
I cannibalized most of the old contrib profiling stuff for Timbre, btw: https://github.com/ptaoussanis/timbre#profiling

 - Peter Taoussanis (@ptaoussanis)

Adrian Mowat

unread,
Aug 6, 2012, 10:08:29 AM8/6/12
to clo...@googlegroups.com
@odyssomay, @Luc thanks very much.  That explains the problems I was having

@Peter, timbre looks very interesting.  Thanks for posting it
Reply all
Reply to author
Forward
0 new messages