-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
display execution time #157
Comments
@daslu Hi, my initial thought was that we can capture the output just like -(defn complete [{:as note
- :keys [comment? code form value]}]
+(defn complete
+ "Complete `note` by evaluating its `code` or `form`."
+ [{:as note
+ :keys [comment? code form value]}]
(-> (if (or value comment?)
note
- (assoc note
- :value (cond code (-> code
- read-string
- eval
- deref-if-needed)
- form (-> form
- eval
- deref-if-needed))))
+ (let [new-out (new java.io.StringWriter)]
+ (binding [*out* new-out]
+ (assoc note
+ :value (->> (cond code (-> code
+ read-string
+ eval
+ deref-if-needed)
+ form (-> form
+ eval
+ deref-if-needed))
+ (str new-out "\n")
+ )))))
(cond-> (not comment?) It turned out this doesn't work as the concat'ed string will be treated as the whole value, that is, What do you think will be a better way to achieve the goal? Thanks. |
Thanks for looking into this. Probably we should measure times ourselves, and probably this should happen in the Anyway, first, we should define the goal better. |
Thanks for replying.
If we measure the time ourselves, isn’t it not flexible enough? For
example, one may want to demonstrate println to show its output and result.
…On Mon, Sep 23, 2024 at 06:03 Daniel Slutsky ***@***.***> wrote:
Thanks for looking into this.
Probably we should measure times ourselves, and probably this should
happen in the scicloj.clay.v2.make namespace.
Anyway, first, we should define the goal better.
We should clarify what times should actually be measured (evaluation?
rendering? etc.) in various workflows.
—
Reply to this email directly, view it on GitHub
<#157 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKVIOXUIJAZMY54R7GKKCTZX45EVAVCNFSM6AAAAABOFHNI56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRWHE4DIMJYGA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Zulip discussion: https://clojurians.zulipchat.com/#narrow/stream/422115-clay-dev/topic/Idea.3A.20display.20execution.20time
The text was updated successfully, but these errors were encountered: