简体   繁体   English

使用系统VS实现包调用perl脚本

[英]calling perl script with system VS implementing package

Let me start with giving an example of what I'm dealing with first: 让我开始举例说明我首先要处理的事情:

I often call existed Perl scripts from previous engineers to process some data, and then proceed further with my script. 我经常调用以前的工程师提供的现有Perl脚本来处理一些数据,然后进一步处理我的脚本。 I either use system or back-ticks to call other people scripts within my script. 我可以使用system调用或back-ticks在脚本中调用其他人的脚本。

Now, I'm wondering if I rewrite those scripts as packages and use require or use to include those packages in my script, will it increase the processing speed? 现在,我想知道是否将那些脚本重写为包,并使用requireuse将这些包包含在我的脚本中,这会提高处理速度吗? How big of a difference would it be? 会有多大的不同?

Benefits: 优点:

  • It would save the time taken to load the shell, load perl , compile the script and the module it uses. 这样可以节省加载外壳,加载perl ,编译脚本及其使用的模块所需的时间。 That's a couple of seconds minimum , but it could be much larger. 这是最少几秒钟的时间,但可能会更大。
  • If you had to serialize data to pass to the child, you also save the time taken to serialize and deserialize the data. 如果必须序列化数据以传递给子级,则还可以节省序列化和反序列化数据所花费的时间。
  • It would allow more flexible interfaces. 它将允许更灵活的接口。
  • It would make error handling easier and more flexible. 这将使错误处理更加容易和灵活。

Downsides: 缺点:

  • Since everything is now in the same process, the child can have a much larger effect on the parent. 由于现在一切都在同一过程中,因此孩子对父母的影响可能更大。 eg A crash in the child will take down the parent. 例如,孩子的崩溃将使父母丧生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM