· projects · 3 min read

Windows ScreenFetch Fast

Windows-screenFetch but faster

Windows-screenFetch but faster

What is this?

screenFetch was originally made as a “Bash Screenshot Information Tool”. Simply, it lets you display detailed information about your system in the terminal, it also comes with a ASCII logo for the detected Linux distribution. This doesn’t work on Windows natively and this project is my attempt to provide a solution that does not require obtaining a linux environment on windows.

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

Average

Before

SystemSpecificationsDisplaysDisksRAMCPUMoboGPUUserInformationShellWMOSUptimeKernelFont
179.3715.6411.8410.577.827.546.991.060.780.771.040.640.710.49
180.3014.4112.3210.708.077.547.461.040.830.790.630.620.560.75
170.8914.3511.8810.227.337.256.641.030.620.740.580.840.570.58
184.1814.2311.5510.697.557.137.121.260.910.770.730.660.670.51
178.5816.4413.1811.728.308.027.291.200.830.830.790.640.610.54
174.2314.0511.2810.207.547.106.891.000.770.710.630.600.560.51
186.1216.1612.6513.098.008.359.361.081.100.850.690.670.610.60
169.8814.2811.4610.827.267.488.101.030.810.730.640.910.560.52
173.2214.2311.6310.417.307.836.961.030.820.760.590.610.560.48
178.1414.2811.9010.287.237.176.641.030.760.750.950.690.720.50
177.491214.805911.969610.87017.63997.54117.34401.07450.82330.77000.72860.68860.61340.5488

After

SystemSpecificationsCPUOSUptimeDisksRAMKernelDisplaysMoboGPUUserInformationShellWMFont
2046.201042.94147.52146.34120.6281.7273.8014.207.327.081.140.720.700.51
2031.291046.87145.46151.21122.0582.3471.8814.827.656.890.970.810.710.70
2046.361049.13148.89156.67119.8581.5675.1414.747.717.620.990.810.750.54
2027.131039.35145.30158.01118.1082.4772.0415.587.647.021.330.830.800.56
2037.481045.87146.35144.62118.9483.5372.8314.346.936.860.980.710.720.47
2038.511046.85144.48143.08122.1984.6972.3014.467.177.200.990.750.760.51
2037.261040.62152.65145.79120.6082.8874.1114.077.046.700.950.730.690.47
2020.481041.06155.49143.36122.3785.9073.6614.216.887.261.310.720.720.51
2034.331039.48160.74149.64122.2582.5375.2014.477.697.191.030.820.770.57
2040.951047.73149.51145.94122.4381.8174.9114.587.777.341.000.790.780.52
2035.99791043.9886149.6388148.4669120.938782.942473.587214.54637.38027.11581.06880.76730.74120.5363

Testing Methodology

  • Use the function speed tests provided in the fork.

  • 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 :).

Back to Blog

Related Posts

View All Posts »

PC Specs

Cross platform desktop app that displays your computer specs

CAO Calculator

Android app that helps calculate how many CAO points you need to qualify for a course.