Technology Microsoft Software & solutions

How to Speed Up Ruby Script

    • 1). Open a Command Prompt. This can be done by navigating to "Start," "All Programs," "Accessories" and "Command Prompt." On Linux, click the menu button, then click on the Terminal. On Mac, access the Terminal in the programs folder.

    • 2). Enter the following code into the Command Prompt.

      ruby -rprofile YourScriptName.rb

      The "-rprofile" before your script runs the Ruby profiler. The command returns a list of the methods that are taking a significant amount of time to complete.

    • 3). Analyze the methods in which your script is spending a significant amount of time. Depending on the nature of the method, certain optimizations may be possible. Eliminate any code that causes the computer to perform redundant computation.



Leave a reply