Windows ScreenFetch Fast
What is this?
TL;DR: Windows-screenFetch brings screenFetch to Windows, my project is a fork that aims to make it faster, so that it can be used as a splash screen.
How much faster is it?
11x faster (in my testing). Around 2 seconds to 0.2 seconds.
2035.9979ms to 177.4912ms
NOTE: The following statistics exclude “Get-” from the function names for readability
Before
SystemSpecifications | CPU | OS | Uptime | Disks | RAM | Kernel | Displays | Mobo | GPU | UserInformation | Shell | WM | Font |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2046.20 | 1042.94 | 147.52 | 146.34 | 120.62 | 81.72 | 73.80 | 14.20 | 7.32 | 7.08 | 1.14 | 0.72 | 0.70 | 0.51 |
2031.29 | 1046.87 | 145.46 | 151.21 | 122.05 | 82.34 | 71.88 | 14.82 | 7.65 | 6.89 | 0.97 | 0.81 | 0.71 | 0.70 |
2046.36 | 1049.13 | 148.89 | 156.67 | 119.85 | 81.56 | 75.14 | 14.74 | 7.71 | 7.62 | 0.99 | 0.81 | 0.75 | 0.54 |
2027.13 | 1039.35 | 145.30 | 158.01 | 118.10 | 82.47 | 72.04 | 15.58 | 7.64 | 7.02 | 1.33 | 0.83 | 0.80 | 0.56 |
2037.48 | 1045.87 | 146.35 | 144.62 | 118.94 | 83.53 | 72.83 | 14.34 | 6.93 | 6.86 | 0.98 | 0.71 | 0.72 | 0.47 |
2038.51 | 1046.85 | 144.48 | 143.08 | 122.19 | 84.69 | 72.30 | 14.46 | 7.17 | 7.20 | 0.99 | 0.75 | 0.76 | 0.51 |
2037.26 | 1040.62 | 152.65 | 145.79 | 120.60 | 82.88 | 74.11 | 14.07 | 7.04 | 6.70 | 0.95 | 0.73 | 0.69 | 0.47 |
2020.48 | 1041.06 | 155.49 | 143.36 | 122.37 | 85.90 | 73.66 | 14.21 | 6.88 | 7.26 | 1.31 | 0.72 | 0.72 | 0.51 |
2034.33 | 1039.48 | 160.74 | 149.64 | 122.25 | 82.53 | 75.20 | 14.47 | 7.69 | 7.19 | 1.03 | 0.82 | 0.77 | 0.57 |
2040.95 | 1047.73 | 149.51 | 145.94 | 122.43 | 81.81 | 74.91 | 14.58 | 7.77 | 7.34 | 1.00 | 0.79 | 0.78 | 0.52 |
2035.9979 | 1043.9886 | 149.6388 | 148.4669 | 120.9387 | 82.9424 | 73.5872 | 14.5463 | 7.3802 | 7.1158 | 1.0688 | 0.7673 | 0.7412 | 0.5363 |
After
SystemSpecifications | Displays | Disks | RAM | CPU | Mobo | GPU | UserInformation | Shell | WM | OS | Uptime | Kernel | Font |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
179.37 | 15.64 | 11.84 | 10.57 | 7.82 | 7.54 | 6.99 | 1.06 | 0.78 | 0.77 | 1.04 | 0.64 | 0.71 | 0.49 |
180.30 | 14.41 | 12.32 | 10.70 | 8.07 | 7.54 | 7.46 | 1.04 | 0.83 | 0.79 | 0.63 | 0.62 | 0.56 | 0.75 |
170.89 | 14.35 | 11.88 | 10.22 | 7.33 | 7.25 | 6.64 | 1.03 | 0.62 | 0.74 | 0.58 | 0.84 | 0.57 | 0.58 |
184.18 | 14.23 | 11.55 | 10.69 | 7.55 | 7.13 | 7.12 | 1.26 | 0.91 | 0.77 | 0.73 | 0.66 | 0.67 | 0.51 |
178.58 | 16.44 | 13.18 | 11.72 | 8.30 | 8.02 | 7.29 | 1.20 | 0.83 | 0.83 | 0.79 | 0.64 | 0.61 | 0.54 |
174.23 | 14.05 | 11.28 | 10.20 | 7.54 | 7.10 | 6.89 | 1.00 | 0.77 | 0.71 | 0.63 | 0.60 | 0.56 | 0.51 |
186.12 | 16.16 | 12.65 | 13.09 | 8.00 | 8.35 | 9.36 | 1.08 | 1.10 | 0.85 | 0.69 | 0.67 | 0.61 | 0.60 |
169.88 | 14.28 | 11.46 | 10.82 | 7.26 | 7.48 | 8.10 | 1.03 | 0.81 | 0.73 | 0.64 | 0.91 | 0.56 | 0.52 |
173.22 | 14.23 | 11.63 | 10.41 | 7.30 | 7.83 | 6.96 | 1.03 | 0.82 | 0.76 | 0.59 | 0.61 | 0.56 | 0.48 |
178.14 | 14.28 | 11.90 | 10.28 | 7.23 | 7.17 | 6.64 | 1.03 | 0.76 | 0.75 | 0.95 | 0.69 | 0.72 | 0.50 |
177.4912 | 14.8059 | 11.9696 | 10.8701 | 7.6399 | 7.5411 | 7.3440 | 1.0745 | 0.8233 | 0.7700 | 0.7286 | 0.6886 | 0.6134 | 0.5488 |
Testing Methodology
Run speed test 5-10 times before taking the real tests so the script stabilizes.
Take 10 real tests and record the results (I use Excel).
Group the results, calculate the averages, and sort the functions based on average speed.
Possible Downfalls
The test uses
Measure-Command
, better alternatives could exist.- I assume that Microsoft knows how to make a decent time measuring utility.
Sample size could be possibly be too small.
- The deviations are pretty minimal
While 5-10 initial tests are performed and discarded for the scripts to stabilize, some kind of caching could be going on that skews the results.
- I assume that since both versions go through this process, there is minimal error.
How was the speed improved?
Filtering
The original doesn’t really filter properties, which increases memory usage and slows down the script.
For example, this is the entire original Get-CPU
function:
Function Get-CPU()
{
return (((Get-CimInstance Win32_Processor).Name) -replace 's+', ' ');
}
If you look at the speed test results above, you can see that this Get-CimInstance
call is responsible for the function taking 1043.99ms
. That is an entire second, and makes up half of the total execution time.
Meanwhile, here is the new one:
Function Get-CPU()
{
return (Get-CimInstance CIM_Processor -Property Name).Name;
}
This improved version takes 7.64ms
, that is 137x faster.
DRY (Don’t-Repeat-Yourself)
Turns out the original calls Get-CimInstance
every time Win32_OperatingSystem
or something else is needed, which can be a very expensive call. My version calls the commonly used instances once and then stores them in a variable.
For example, this original function takes 149.64ms
:
Function Get-OS()
{
return (Get-CimInstance Win32_OperatingSystem).Caption + " " +
(Get-CimInstance Win32_OperatingSystem).OSArchitecture;
}
Meanwhile, the new one takes 0.73ms
(205x faster):
$osx = Get-CimInstance Win32_OperatingSystem
# ...
Function Get-OS()
{
return $osx.Caption + " " +
$osx.OSArchitecture;
}
Those are the main ones, here is the commit that added all of the speed improvements.
Where can I get it?
Here is the GitHub page. Alternatively, install it through Powershell Gallery:
Install-Module -Name windows-screenfetch-fast
If you’re having errors, here is a solution:
“If you have followed the installation steps but you’re getting the following error:
> The file C:<yourpath>screenfetch.ps1 is not digitally signed.
> The script will not execute on the system.
A common fix is to run the powershell command Set-ExecutionPolicy Unrestricted in a shell with administrative privileges.” - Here is the original :).