我正在计算处理时间
start =: 6!:0 ''
在我的代码顶部
end =: (6!:0 '') - start
在我的代码末尾。但是,我是否可以在J中实现这样的状态栏呢?
[==== ] 25%
[============ ] 50%
[==========================] 100%
谢谢!
发布于 2018-05-22 22:22:39
如果我理解您的问题,您可以使用系统定义为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
https://stackoverflow.com/questions/50476475
复制相似问题