Reputation: 765
I am calculating the processing time by putting
start =: 6!:0 ''
at the top of my code and putting
end =: (6!:0 '') - start
at the end of my code. However, is there any way that I can implement a status bar like this in J?
[==== ] 25%
[============ ] 50%
[==========================] 100%
Thank you!
Upvotes: 1
Views: 68
Reputation: 4302
If I understand your question, you could use smoutput
defined as 0 0 $ 1!:2&2
by the system to display your processing milestones on the screen
someverb =: 3 : 0
smoutput '{ }'
code
smoutput '{+++ }'
more code
smoutput '{+++++ }'
more code
smoutput '{++++++++}'
)
but you would have to know that the places that you insert the smoutput expressions would correspond to the amount of processing that had taken place.
As an example:
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
or closer to the output you would like
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
Upvotes: 1