简体   繁体   English

如何在ClojureScript Browser REPL中计时?

[英]How can I time functions in a ClojureScript Browser REPL?

I have a bit of experience with Clojure, but I am new to ClojureScript. 我对Clojure有一些经验,但我是ClojureScript的新手。 I have been working on some code that was written by someone else. 我一直在研究一些由其他人编写的代码。 It uses a browser repl in sublimetext, connected to a browser via a port and a brepl-connected.html file. 它使用sublimetext中的浏览器repl,通过端口和brepl-connected.html文件连接到浏览器。 I tried to time the length of a function using (time (function arg)) in the repl, but the output is 0 msecs no matter what. 我尝试在repl中使用(time (function arg))来计算函数的长度,但无论如何输出都是0毫秒。 Why does this happen? 为什么会这样?

I've tried something like (.time js/console label) , but this always returns some unintelligble object to the console. 我尝试了类似(.time js/console label) ,但这总是会向控制台返回一些不可理解的对象。

I'd like to be able to time functions and, in general, be able to use print statements and other tools to debug and improve my code. 我希望能够计时功能,并且通常能够使用打印语句和其他工具来调试和改进我的代码。 What is the best method to do this? 这样做的最佳方法是什么? Should I have returns go to the repl or to the browser? 我应该有回复转到repl或浏览器吗?

Thanks in advance, I've looked around but I can't find a good article or post explaining this. 提前谢谢,我环顾四周,但找不到好的文章或帖子解释这个。

This blog post explains how you can do this with a macro: 此博客文章介绍了如何使用宏执行此操作:

http://blog.jenkster.com/2015/09/timing-code-in-clojurescript.html http://blog.jenkster.com/2015/09/timing-code-in-clojurescript.html

Are you wrapping your call in a .time and .timeEnd ? 你是在.time.timeEnd打包你的电话吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM