我正在计算处理时间
start =: 6!:0 ''
在我的代码顶部并放置
end =: (6!:0 '') - start
在我的代码结束时。但是,有什么方法可以在J?
中实现这样的状态栏[==== ] 25%
[============ ] 50%
[==========================] 100%
谢谢!
答案 0 :(得分:1)
如果我理解了您的问题,您可以使用系统smoutput
定义为0 0 $ 1!:2&2
来在屏幕上显示您的处理里程碑
someverb =: 3 : 0
smoutput '{ }'
code
smoutput '{+++ }'
more code
smoutput '{+++++ }'
more code
smoutput '{++++++++}'
)
但您必须知道插入smoutput表达式的位置将与已发生的处理量相对应。
举个例子:
test =: 3 : 0
smoutput 6!:0 'hh:mm:ss.sss'
6!:3 (2) NB. 2 second delay
smoutput 6!:0 'hh:mm:ss.sss'
6!:3 (2) NB. 2 second delay
smoutput 6!:0 'hh:mm:ss.sss'
)
test ''
14:53:42.313
14:53:44.317 NB. after two second delay
14:53:46.326 NB. after two second delay
或更接近您想要的输出
test1 =: 3 : 0
start=. 6!:0 ''
smoutput '[ ] 0%'
6!:3 (2) NB. 2 second delay
smoutput '[=== ] 25%'
6!:3 (2) NB. 2 second delay
smoutput '[====== ] 50%'
6!:3 (4) NB. 4 second delay
smoutput '[============] 100%'
(6!:0 '')- start
)
test1 ''
[ ] 0%
[=== ] 25%
[====== ] 50%
[============] 100%
0 0 0 0 0 8.01821