Progress bar (again)

Thursday, 9 March 2023 · 5 messages · last reply 16 Mar 2023
ZD
Zimmel, Daniel9 Mar 2023 17:14 #
Hey, I have a task that may take longer to execute (several minutes), so I felt I got to have a fancy progress bar on the command line to entertain me. No progress bar though, found this in the archives: https://mailman.uni-konstanz.de/pipermail/basex-talk/2020-November/015845.html So this is the closest I got (running BaseX from an Ant task): xquery_update_db: [echo] XQuery Update (Database) wird ausgeführt: xquery/basex.reduce.xquery [apply] EXPORTER: omit-xml-declaration=no [apply] Database 'DEBUGX' was opened in 113.62 ms. [apply] "FORTSCHRITT: 0%" [apply] "FORTSCHRITT: *****5%" [apply] "FORTSCHRITT: **********10%" [apply] "FORTSCHRITT: ***************15%" [apply] "FORTSCHRITT: ********************20%" [apply] "FORTSCHRITT: *************************25%" While I am happy enough with this (it is quite accurate and I like the dramatically mounting effect), can anyone say what might be needed to implement this as a module? Daniel
CG
Christian Grün9 Mar 2023 17:24 #
Hi Daniel,
Quoted text · Zimmel, Daniel · 1 line
> can anyone say what might be needed to implement this as a module?
Looks interesting! I hope our Wiki article on creating and installing modules is helpful [1]. Cheers, Christian [1] https://docs.basex.org/wiki/Repository
Quoted text · Zimmel, Daniel · 3 lines
> > Daniel >
ZD
Zimmel, Daniel15 Mar 2023 09:14 #
Thanks, I was hoping there might be some way to update the output result instead of simply adding to output. I just ran a 420 minutes regular expressions query, which I might be going to optimize now because there is not much visible progress anymore :-P
Quoted text · Christian Grün · 15 lines
-----Ursprüngliche Nachricht----- Von: Christian Grün <christian.gruen at gmail.com> Gesendet: Donnerstag, 9. März 2023 17:25 An: Zimmel, Daniel <D.Zimmel at ESVmedien.de> Cc: basex-talk at mailman.uni-konstanz.de Betreff: Re: [basex-talk] Progress bar (again) Hi Daniel, > can anyone say what might be needed to implement this as a module? Looks interesting! I hope our Wiki article on creating and installing modules is helpful [1]. Cheers, Christian [1] https://docs.basex.org/wiki/Repository > > Daniel >
CG
Christian Grün15 Mar 2023 17:36 #
Quoted text · Zimmel, Daniel · 2 lines
> Thanks, I was hoping there might be some way to update the output result instead of simply adding to output. > I just ran a 420 minutes regular expressions query, which I might be going to optimize now because there is not much visible progress anymore :-P
Sorry, now I got it. You could try something like this:
for $i in 1 to 100
let $string := string-join((
  (: yields &#xd;, and jumps to the beginning of the current line :)
  string:cr(),
  'FORTSCHRITT: ',
  (1 to $i idiv 5) ! '.',
  $i, '%'
))
return (
  prof:sleep(50),
  (: calls System.err.println($string) :)
  Q{java.lang.System}err() => Q{java.io.PrintStream}print($string)
)
I think we won’t offer a built-in function for that, as the result of functions like fn:trace, prof:dump, etc. will be sent to different output channels, some of which won’t allow the overwriting of output that has previously been sent. Hope this helps, Christian
ZD
Zimmel, Daniel16 Mar 2023 10:44 #
Yes, this works great in the console! However I can see why it is better to stick to the standard functions. In my case, this does not work when running via an Ant apply task, since Ant has its own loggers and is doing something internally which prevents jumping to the start of the line. Perhaps there is a way to do this with Ant, but I do not think this is a good idea for portability... Thanks for the insight, Daniel
Quoted text · Christian Grün · 27 lines
-----Ursprüngliche Nachricht----- Von: Christian Grün <christian.gruen at gmail.com> Gesendet: Mittwoch, 15. März 2023 17:37 An: Zimmel, Daniel <D.Zimmel at ESVmedien.de> Cc: basex-talk at mailman.uni-konstanz.de Betreff: Re: [basex-talk] Progress bar (again) > Thanks, I was hoping there might be some way to update the output result instead of simply adding to output. > I just ran a 420 minutes regular expressions query, which I might be > going to optimize now because there is not much visible progress > anymore :-P Sorry, now I got it. You could try something like this: for $i in 1 to 100 let $string := string-join(( (: yields &#xd;, and jumps to the beginning of the current line :) string:cr(), 'FORTSCHRITT: ', (1 to $i idiv 5) ! '.', $i, '%' )) return ( prof:sleep(50), (: calls System.err.println($string) :) Q{java.lang.System}err() => Q{java.io.PrintStream}print($string) ) I think we won’t offer a built-in function for that, as the result of functions like fn:trace, prof:dump, etc. will be sent to different output channels, some of which won’t allow the overwriting of output that has previously been sent. Hope this helps, Christian

⚡Generated with XQuery