2

每当我尝试p在函数中包含 Timbre 语句时,都会出现错误:

项目.clj

 (defproject sketch "0.1.0-SNAPSHOT"
      :description "FIXME: write description"
      :url "http://example.com/FIXME"
      :license {:name "Eclipse Public License"
                :url "http://www.eclipse.org/legal/epl-v10.html"}
      :dependencies [[org.clojure/clojure "1.5.1"]
                     [com.taoensso/timbre "3.1.1"]])

核心.clj

(ns user (:require [taoensso.timbre :as timbre])) 
(timbre/refer-timbre)

(defn tst [a]
  (p :tf (+ a a)))

输出(苹果酒/nrepl)

 Unable to resolve symbol: p in this context, compiling:(NO_SOURCE_PATH:2:3)

但其他音色功能/宏喜欢profile并且spy工作正常。

4

2 回答 2

2

分析p未使用 refer-timbre 公开,文档似乎已过时。

(require
   '[taoensso.timbre.profiling :as profiling :refer (pspy pspy* profile defnp)])

正如你在这里看到的p只是一个别名pspy

 (defmacro p [id & body] `(pspy ~id ~@body)) ; Alias

所以你可以pspy改用。

于 2014-03-07T02:42:14.083 回答
0

如果您只是对开发时间函数所花费的时间感兴趣,就足够了。

(time (some-work))
于 2019-02-19T12:25:44.030 回答