On Friday, August 26, 2016 at 12:02:38 AM UTC+3, Bram Moolenaar wrote:
> Ramel Eshed wrote:
>
> > On Thursday, August 11, 2016 at 3:08:01 AM UTC+3, Ramel Eshed wrote:
> > > On Thursday, August 11, 2016 at 2:19:38 AM UTC+3, Tony Mechelynck wrote:
> > > > There are other factors which are right there in the help:
> > > > - job_start() returns a Job object and doesn't wait for the job to
> > > > finish
> > > > - system() waits for the external command to finish and returns its
> > > > full stdout output as a string.
> > > >
> > > > I don't know Vim job control really well, but I seem to understand
> > > > that in order to compare system() timing and job control timing you
> > > > would have to set up callbacks to gather any output from the channel,
> > > > and a callback to be called when the job ends (it may still write to
> > > > stdout after it exits), and measure the time from just before
> > > > job_start() to just after making sure that all output has been
> > > > collected and that the job has ended.
> > > >
> > > > You might even, for testing purposes, try to write a System() user
> > > > function to invoke the argument as a job and return its output as a
> > > > string, with the disadvantage that you would completely lose job
> > > > control asynchronism. But it would allow you a better comparison,
> > > > namely between old-fashioned system() and this new job-control-based
> > > > System().
> > > >
> > > > Best regards,
> > > > Tony.
> > >
> > > That's exactly what I've did:
> > >
> > > func! Job()
> > > let s:rt = reltime()
> > > let g:output = []
> > > let g:job = job_start(['/bin/sh', '-c', 'cat ' . expand('%')],
> > > {'out_cb': function('s:out_cb'), 'close_cb': function('s:close_cb')})
> > > endfunc
> > >
> > > func! s:out_cb(channel, msg)
> > > call add(g:output, a:msg)
> > > endfunc
> > >
> > > func! s:close_cb(channel)
> > > echo reltimestr(reltime(s:rt))
> > > "echo g:output
> > > endfunc
> > >
> > > " compare with:
> > >
> > > func! System()
> > > let s:rt = reltime()
> > > let g:output = systemlist('cat ' . expand('%'))
> > > echo reltimestr(reltime(s:rt))
> > > endfunc
> > >
> > > """""""""""""
> > > I checked it now on my Ubuntu at home - I still see the difference but
> > > now both are much faster so even the system() delay is not noticeable.
> > > Any idea what could cause the delay on my RHEL?
> > >
> > > BTW, if I remove the comment from the 'echo g:output' line in close_cb()
> > > the message is not displayed (actually, it depends on which command is
> > > running. for the 'cat' command above -there is no message).
> >
> > Hi Bram,
> >
> > Is it possible to make system() work the same way job_start (with a
> > shell) does? As I mentioned, I get a noticeable delay with system()
> > which I don't get when using job_start(['/bin/sh'...).
>
> Not sure if there is anything to improve. Would require finding out why
> it's slower and whether that can be fixed.
>
> You could add channel log commands in the code in various places to see
> what happens.
>
> --
> hundred-and-one symptoms of being an internet addict:
> 76. Your ISP regards you as a business partner rather than as a customer.
>
> /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
> /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\ an exciting new programming language -- http://www.Zimbu.org ///
> \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
My problem is not with the channel, the problem is that system() is slower than
the equivalent job_start(). You can run and compare the results of Job() and
System() functions in the attached file. They are both doing the same thing
('echo aaa') but System() is ~5 times slower than Job() on Ubuntu and x10
slower on RHEL5.5. On RHEL System() is extremely slow, it takes about 0.2
seconds which cause Vim to hang.
Thanks,
Ramel
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
system.vim
Description: Binary data
