├── VERSION ├── .gitignore ├── bench.cmd ├── fastlist.cpp ├── test.cmd └── README.md /VERSION: -------------------------------------------------------------------------------- 1 | 0.3.0 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | timeit.dat 3 | -------------------------------------------------------------------------------- /bench.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if not exist timeit.exe ( 4 | curl -LO https://github.com/MarkTiedemann/rktools2k3/raw/master/timeit.exe 5 | ) 6 | 7 | if exist timeit.dat ( 8 | del timeit.dat 9 | ) 10 | 11 | :: Get carriage return 12 | for /f %%c in ('copy /z %~f0 nul') do ( 13 | for /f %%v in (VERSION) do ( 14 | for /l %%i in (1, 1, 100) do ( 15 | < nul set /p="Run: %%i/100%%c" 16 | timeit.exe tasklist.exe > nul 2> nul 17 | timeit.exe wmic.exe process get name,processid,parentprocessid > nul 2> nul 18 | for %%a in (x86 x64) do ( 19 | timeit.exe fastlist-%%v-%%a.exe > nul 2> nul 20 | ) 21 | ) 22 | < nul set /p=%%c 23 | ) 24 | ) 25 | 26 | timeit.exe -t 27 | -------------------------------------------------------------------------------- /fastlist.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 8 | if (snap == INVALID_HANDLE_VALUE) 9 | return 1; 10 | 11 | PROCESSENTRY32 entry; 12 | entry.dwSize = sizeof(PROCESSENTRY32); 13 | 14 | if (!Process32First(snap, &entry)) { 15 | CloseHandle(snap); 16 | return 1; 17 | } 18 | 19 | do { 20 | CW2A exe(entry.szExeFile, CP_UTF8); 21 | std::cout 22 | << entry.th32ProcessID << '\t' 23 | << entry.th32ParentProcessID << '\t' 24 | << exe.m_psz << '\n'; 25 | } while (Process32Next(snap, &entry)); 26 | CloseHandle(snap); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /test.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | 4 | :: Determine Windows version using `ver` 5 | :: C:\>ver 6 | :: Microsoft Windows [Version 10.0.18362.657] 7 | for /f "delims=" %%i in ('ver') do set ver=%%i 8 | :: Cut version string from command output 9 | :: - Remove first 27 chars ("Microsoft Windows [Version ".length) from the start of the string 10 | :: - Remove last char ("]") from the end of the string 11 | set windows_version=%ver:~27,-1% 12 | :: => 10.0.18362.657 13 | 14 | where docker > nul 2> nul 15 | if %errorlevel% neq 0 ( 16 | echo Error: Please install Docker for Windows 2>&1 17 | exit /b 1 18 | ) 19 | 20 | docker version > nul 2> nul 21 | if %errorlevel% neq 0 ( 22 | echo Error: Please start Docker 2>&1 23 | exit /b 1 24 | ) 25 | 26 | docker info | findstr OSType: | findstr windows > nul 2> nul 27 | if %errorlevel% neq 0 ( 28 | echo Error: Please switch to Docker Windows containers 2>&1 29 | exit /b 1 30 | ) 31 | 32 | docker images | findstr %windows_version% > nul 2> nul 33 | if %errorlevel% neq 0 ( 34 | echo Warning: Pulling required image from Docker Hub 2>&1 35 | docker pull mcr.microsoft.com/windows:%windows_version% 36 | ) 37 | 38 | for /f %%v in (VERSION) do ( 39 | for %%a in (x86 x64) do ( 40 | docker run --rm --tty --volume %cd%:C:\volume mcr.microsoft.com/windows:%windows_version% cmd /c .\volume\fastlist-%%v-%%a.exe 41 | if %errorlevel% neq 0 ( 42 | echo Error: Test failed with error level: %errorlevel% 43 | exit /b 1 44 | ) 45 | ) 46 | ) 47 | 48 | echo. 49 | echo Info: Test passed 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fastlist 2 | 3 | **Like `tasklist`, but 10x faster.** 4 | 5 | ``` 6 | Name Process Time System Context Page Total I/O 7 | Calls Switches Faults 8 | fastlist 0:00:00.014 7331 1879 1774 176124 9 | tasklist 0:00:00.165 124549 51150 9017 4001389 10 | ``` 11 | 12 | For each process, `fastlist` prints (1) the **process ID**, (2) the **parent process ID**, and (3) the **executable file**, each separated by a `\t`, followed by a `\n`. For example: 13 | 14 | ```batch 15 | > fastlist.exe 16 | 0 0 [System Process] 17 | 4 0 System 18 | 72 4 Secure System 19 | 128 4 Registry 20 | 520 4 smss.exe 21 | 776 640 csrss.exe 22 | 864 640 wininit.exe 23 | ... 24 | ``` 25 | 26 | `fastlist` is faster than `tasklist`, presumably, because it does _not_ print the **session name**, **session number**, nor the **memory usage** of each process. Unlike `tasklist`, it does, however, print the **parent process ID**. 27 | 28 | ## Releases 29 | 30 | - [**v0.3.0**](https://github.com/MarkTiedemann/fastlist/releases/tag/v0.3.0) (June 15, 2020): Include runtime library; Revert packing binaries 31 | - [**v0.2.1**](https://github.com/MarkTiedemann/fastlist/releases/tag/v0.2.1) (May 23, 2020): Packed binaries 32 | - [**v0.2.0**](https://github.com/MarkTiedemann/fastlist/releases/tag/v0.2.0) (May 23, 2020): Unicode support; x86 and x64 build 33 | - [**v0.1.0**](https://github.com/MarkTiedemann/fastlist/releases/tag/v0.1.0) (Oct 5, 2018): Initial release 34 | 35 | ## Notes 36 | 37 | - `fastlist` was originally built for use in [sindresorhus/ps-list](https://github.com/sindresorhus/ps-list) (see [sindresorhus/ps-list#20](https://github.com/sindresorhus/ps-list/issues/20)). 38 | - It is inspired by performance issues with existing solutions (for example, [sindresorhus/fkill#25](https://github.com/sindresorhus/fkill/issues/25)). 39 | - Being included in [npmjs.com/ps-list](https://www.npmjs.com/package/ps-list), `fastlist` is downloaded more than 1,000,000 times per week. 40 | - [Reddit rumors](https://www.reddit.com/r/javascript/comments/f0kmqd/askjs_fastlistexe_was_flagged_as_a_malware_by_my/) to the contrary notwithstanding, it is not a virus. 41 | - Its author helps to maintain the Node wrapper for `tasklist`: [sindresorhus/tasklist](https://github.com/sindresorhus/tasklist). 42 | 43 | ## Development 44 | 45 | - Download and install [Microsoft Visual Studio](https://visualstudio.microsoft.com/), including its workload for _Desktop Development with C++_. In VS, create a new _Console App_. Copy [`fastlist.cpp`](fastlist.cpp) into the project and build it. 46 | - To benchmark `fastlist`, run [`bench.cmd`](bench.cmd). 47 | - To test `fastlist`, run [`test.cmd`](test.cmd). 48 | 49 | ## License 50 | 51 | MIT 52 | --------------------------------------------------------------------------------