Skyrim

File information

Last updated

Original upload

Created by

JustinOther and Cipscis

Uploaded by

JustinOther

Virus scan

Safe to use

Tags for this mod

About this mod

Compare code snippets' efficiency.

Permissions and credits
Name: Code Comparer (Papyrus)

Thread @ Bethsoft: http://forums.bethsoft.com/topic/1409880-relz-wipz-code-comparer-papyrus/

By: JustinOther (Isaak Mills) and Cipscis (Mark Hanna)

Version: 1.00

Description: This is a utility designed for testing the efficiency of Papyrus snippets in the time honored tradition of Cipscis' Code Comparers for Fallouts. There's often more than one way to skin a cat, but which way is the most efficient? This tool aims to provide an easy way to measure multiple snippets' speed/efficiency. While the efficiency of any single script or line of code is generally inconsequential, every little bit helps, so cumulatively scripts' efficiency does matter. There are eight empty slots at the top of CodeComparerQuestScript.PSC numbered 0-7. The tests will iterate the inserted code an allotted number of times (default is 10^4 or 10,000 iterations) upon selection from the "Test" submenu, recording the relevant information to %UserName%\Documents\My Games\Skyrim\Logs\User\Code Comparer.log and the associated Profiling logs. If multiple snippets from within the menu before beginning a test, the fastest snippet will be reported.

Requirements: Skyrim v1.6.0.89 or later.

Installation: Unpack the contents of the .7z into Skyrim\Data. Activate Code Comparer.esp when testing.

Uninstallation: Deactivate the plugin and/or delete the associated files.

Other contents:

Code Comparer.ini: This enables the necessary debug features such as logging, profiling, etc.

Code Comparer - Purge logs.bat: It's just a quick way to delete all the .log files that accumulate, making it easier to find your test results and/or clean up your Logs directory after testing.

Script Logs - Shortcut.lnk: It's just a shortcut to the script log folder for easy access. You can drop the .bat into the shortcut after installation to store it with the .log files it deletes.

Use: Insert code into the empty slots found in CodeComparerQuestScript.PSC's SpeedTest function (it's right up top) and compile. Make sure Code Comparer.esp is set to load with the launcher and load a save, preferably a clean save in an area with little going on. To start tests open Code Comparer's menu. Depending upon whether SKSE is installed or not, the menu is accessed differently.
If a sufficiently current version of SKSE is installed: Press and briefly hold R-Shift (key is rebindable from within menu)
If SKSE is not installed or is an insufficiently current version: You will find an apparel item, [Code Comparer], in your inventory. When equipped, the menu will be prompted.
Once in the menu, you can choose the "Test" submenu, and select the snippet to test. You'll see a notification about the test starting and completing along with the time elapsed once a test is complete. This information and more is recorded in the aforementioned logs. By default, tests will iterate 10,000 times, but you can adjust the iterations from within the "Options" submenu. Note that the menu will not come back up until the current test is completed and that there's no way to cancel the tests for the sake of isolating the snippets and not adding overhead. Taking larger samples will render more accurate results, but be prepared to wait awhile as some tests may take a long time to finish. Note that Code Comparer, in order to increase the accuracy of the results, calibrates itself to offset the overhead of an empty test. Changing the iterations value will prompt recalibration which might take a moment if using higher values.

Profiling: "The profiling log format is as follows:

<current time="" in="" ms="">:<tag>:<stack id="">:<stack frame="">:<self>:<function>

With <function> being the standard <script>.<state>.<name> format. The stack ID is there to help you separate multiple stacks (threads) in the same log - or to track the same thread through multiple logs, the frame is the current depth of the stack, and the "tag" will be one of the following:

START - start of logging
DONE - end of logging
PUSH - function started running
POP - function returned
QUEUE_PUSH - function was requested to run, but can't yet
QUEUE_POP - function requested to return, but caller can't resume yet

So, for example, the amount of time between a QUEUE_PUSH and a PUSH indicates how long the VM had to wait because the object being called was most likely in use by someone
else, if you see that a lot you might be over-using the same object and throttling yourself as everyone has to wait their turn to run." --SmkViper

Note: If running multiple tests, each test will produce its own Profiling logs. In the first above example, for instance, Script_codecomparerquestscript.0.log correlates with Test #1 while Script_codecomparerquestscript.1.log correlates with Test #0 because Test #1 was run after Test #0 and the most recent log will be the 0. If running multiple tests consecutively, run them in reverse order and the profiling log prefixes will numerically match the tests as listed in the Test function, menu, and TraceUser output provided there aren't preexisting logs when the game is started.

Rights: We're lefties. Do ...whatever.

Thanks: Beth for Skyrim and the Creation Kit. SmkViper (Jeff Lundin) for Papyrus and the ever so helpful information regarding profiling. The SKSE Team for enabling the time saving hotkey.