• Stars
    star
    487
  • Rank 90,352 (Top 2 %)
  • Language
    C++
  • Created almost 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Print swap usage per process. Implemented in various programming languages

swapview is a simple program to view processes' swap usage on Linux. This repository is the one of multiple implementations, intended to be a lilydjwg's version of Hello World program. For a daily use version, see swapview.

How to run the speed comparison

Install all the dependencies for your interested versions, then run make -k. It will build all that can be built.

To test and see the speed comparison, either use bench.py or run_benchmark. bench.py uses Python 3.4+ and depends on python-toml.

run_benchmark is a Rust version. Install latest Rust and Cargo, then change your working directory to benchmark and run cargo build --release. If the build fails, it's because your Rust is too old or too new....

Run ./run_benchmark <benchmark.toml and wait for it to finish. Failed ones (e.g. because you don't have the dependencies installed) will be marked as failed so you don't need to edit benchmark.toml to disable the ones you can't run.

You can give ./run_benchmark names to selectively run some versions, e.g.

./run_benchmark C C++14 'Rust*' <benchmark.toml

Implementions and their requirements

Of course you should have corresponding compilers / interpreters installed. You can (edit and then) run make to build all that needs to be built.

  • Bash, requires bc
  • Bash_parallel, Bash version using GNU parallel
  • C
  • C++98
  • C++98_omp, openmp paralleled version
  • C++14
  • C++14_boost, C++ version using the boost library
  • C++17
  • CSharp (mono)
  • ChezScheme
  • Chicken, format (will be installed by make)
  • CommonLisp_opt, sbcl
  • CommonLisp_old, sbcl, maynbe others also work
  • CoffeeScript, requires promise (will be installed by make)
  • CoffeeScript_parallel, a parallel version, requires promise (will be installed by make)
  • Crystal, with fiber and multi-process versions, tested with 0.28.0
  • Cython
  • D, dmd or ldmd (LLVM version)
  • Dart
  • Elixir
  • Erlang
  • Go >=1.8
  • Guile >= 2.1
  • Haskell, requires haskell-strict
  • Java, >= Java 8
  • Lua, requires lua-filesystem, works with 5.1, 5.2, 5.3 and LuaJIT
  • Nim (tested with 0.17.0)
  • NodeJS, requires sprintf (will be installed by make)
  • NodeJS_async, another NodeJS version which use async I/O, requires sprintf and async (will be installed by make)
  • NodeJS_cluster, uses multiple forked worker process via Node Cluster API
  • OCaml
  • FreePascal
  • Perl
  • Python, works with Python 2 & 3
  • Python3_bytes
  • R
  • Racket
  • Ruby and Rubinius
  • Rust, >= 1.20
  • Scala
  • Vala, requires glib2 (libglib-2.0 and libgio-2.0)
  • Tcl, >= 8.6
  • Zig, tested with 0.9.1

Contributions

Contributions are welcome! Improve current ones, or submit new one. But make sure your implementations meet the following requirements:

  1. Must be readable and maintainable
  2. Output exact the same format as other versions (but sorting may be unstable)
  3. Try to be efficient
  4. Please include a Makefile if appropriate
  5. Don't forget to tell the compiler to optimize

My Result

This is tested on Arch Linux, with latest versions of compilers and interpreters available there at testing time. CPU is Intel(R) Core(TM) i7-7700HQ.

Updated at 2020-06-13:

           Rust_parallel: top:   31.48, min:   29.66, avg:   32.83, max:   36.90, mdev:    1.86, cnt:  20
               C++98_omp: top:   49.14, min:   45.32, avg:   53.43, max:   72.15, mdev:    6.00, cnt:  20
         Crystal_process: top:   65.50, min:   64.67, avg:   69.53, max:   90.86, mdev:    6.32, cnt:  20
            Go_goroutine: top:   96.19, min:   80.59, avg:  107.33, max:  152.03, mdev:   15.97, cnt:  20
                    Rust: top:  105.02, min:  104.25, avg:  106.21, max:  109.86, mdev:    1.64, cnt:  20
                   C++98: top:  142.99, min:  141.01, avg:  145.01, max:  151.68, mdev:    2.62, cnt:  20
                   C++17: top:  143.39, min:  141.34, avg:  145.20, max:  149.27, mdev:    2.15, cnt:  20
             C++14_boost: top:  144.02, min:  142.48, avg:  147.36, max:  161.02, mdev:    4.98, cnt:  20
                   C++14: top:  144.63, min:  142.52, avg:  146.46, max:  151.17, mdev:    2.27, cnt:  20
                       C: top:  144.65, min:  141.69, avg:  152.78, max:  191.49, mdev:   11.96, cnt:  20
                     PHP: top:  145.38, min:  143.82, avg:  147.61, max:  156.60, mdev:    3.28, cnt:  20
              Python3_mp: top:  157.63, min:  152.96, avg:  160.75, max:  167.09, mdev:    3.74, cnt:  20
                   C++11: top:  171.00, min:  168.77, avg:  172.47, max:  181.06, mdev:    2.43, cnt:  20
                  Cython: top:  181.13, min:  179.10, avg:  183.45, max:  192.59, mdev:    2.98, cnt:  20
                      Go: top:  193.06, min:  191.68, avg:  195.08, max:  201.55, mdev:    2.64, cnt:  20
                    Vala: top:  196.43, min:  193.41, avg:  200.22, max:  212.19, mdev:    4.70, cnt:  20
         D_parallel_llvm: top:  196.72, min:  191.97, avg:  200.57, max:  213.42, mdev:    5.15, cnt:  20
              D_parallel: top:  205.46, min:  199.73, avg:  208.67, max:  216.93, mdev:    4.29, cnt:  20
                 Crystal: top:  214.76, min:  210.48, avg:  217.29, max:  224.11, mdev:    3.25, cnt:  20
           Crystal_fiber: top:  226.87, min:  225.04, avg:  233.10, max:  272.75, mdev:   12.50, cnt:  20
                  LuaJIT: top:  226.97, min:  224.28, avg:  231.18, max:  240.60, mdev:    4.86, cnt:  20
        Haskell_parallel: top:  227.06, min:  216.14, avg:  235.88, max:  260.16, mdev:   11.77, cnt:  20
                   OCaml: top:  230.78, min:  229.04, avg:  233.81, max:  242.57, mdev:    3.83, cnt:  20
                 Python2: top:  232.30, min:  228.44, avg:  235.14, max:  245.36, mdev:    3.79, cnt:  20
                  NodeJS: top:  235.54, min:  233.22, avg:  239.51, max:  254.48, mdev:    5.11, cnt:  20
                    PyPy: top:  247.96, min:  244.07, avg:  253.04, max:  285.93, mdev:    8.61, cnt:  20
                  D_llvm: top:  249.79, min:  247.05, avg:  259.87, max:  312.30, mdev:   17.22, cnt:  20
                 Python3: top:  255.07, min:  254.20, avg:  260.64, max:  281.31, mdev:    7.91, cnt:  20
           Python3_bytes: top:  257.99, min:  252.36, avg:  265.09, max:  289.54, mdev:   10.23, cnt:  20
                       D: top:  267.79, min:  266.07, avg:  272.18, max:  301.44, mdev:    7.70, cnt:  20
                     Nim: top:  279.93, min:  278.35, avg:  286.19, max:  314.88, mdev:    8.93, cnt:  20
                    Ruby: top:  281.40, min:  278.51, avg:  285.42, max:  296.61, mdev:    5.06, cnt:  20
                   Lua51: top:  286.97, min:  282.82, avg:  292.06, max:  316.65, mdev:    7.19, cnt:  20
                  Erlang: top:  290.70, min:  219.62, avg:  329.77, max:  393.73, mdev:   51.76, cnt:  20
                   Lua52: top:  294.91, min:  290.32, avg:  300.19, max:  322.82, mdev:    7.16, cnt:  20
                    Perl: top:  300.15, min:  296.57, avg:  307.49, max:  323.94, mdev:    8.76, cnt:  20
                   Lua53: top:  309.14, min:  304.81, avg:  314.05, max:  332.84, mdev:    6.66, cnt:  20
                 Haskell: top:  326.48, min:  323.48, avg:  331.62, max:  346.78, mdev:    6.34, cnt:  20
                 Chicken: top:  376.63, min:  370.26, avg:  382.90, max:  426.14, mdev:   11.16, cnt:  20
             PyPy3_bytes: top:  409.92, min:  398.71, avg:  422.03, max:  468.93, mdev:   17.08, cnt:  20
              FreePascal: top:  417.88, min:  415.39, avg:  423.13, max:  453.09, mdev:    8.20, cnt:  20
          NodeJS_cluster: top:  422.85, min:  409.16, avg:  430.56, max:  444.07, mdev:    9.24, cnt:  20
            CoffeeScript: top:  440.48, min:  420.74, avg:  469.86, max:  555.34, mdev:   38.53, cnt:  20
              ChezScheme: top:  454.38, min:  451.57, avg:  459.67, max:  471.25, mdev:    6.15, cnt:  20
                   PyPy3: top:  456.18, min:  449.58, avg:  474.78, max:  521.61, mdev:   22.42, cnt:  20
                    Java: top:  462.47, min:  455.63, avg:  468.49, max:  478.00, mdev:    6.90, cnt:  20
                   Guile: top:  489.58, min:  478.95, avg:  499.54, max:  529.63, mdev:   13.28, cnt:  20
   CoffeeScript_parallel: top:  500.05, min:  481.84, avg:  524.93, max:  588.15, mdev:   30.29, cnt:  20
            NodeJS_async: top:  518.14, min:  484.02, avg:  548.72, max:  619.11, mdev:   36.99, cnt:  20
                     Tcl: top:  519.87, min:  504.80, avg:  529.65, max:  553.50, mdev:   12.06, cnt:  20
             Dart_native: top:  622.26, min:  616.78, avg:  634.25, max:  675.66, mdev:   16.27, cnt:  20
          CommonLisp_opt: top:  643.17, min:  638.69, avg:  654.79, max:  697.46, mdev:   14.71, cnt:  20
          CommonLisp_old: top:  678.22, min:  669.22, avg:  688.15, max:  701.31, mdev:   11.21, cnt:  20
                   Julia: top:  709.08, min:  702.52, avg:  721.52, max:  753.88, mdev:   15.30, cnt:  20
         Racket_compiled: top:  807.49, min:  799.71, avg:  820.90, max:  852.44, mdev:   15.17, cnt:  20
                  Racket: top:  809.93, min:  802.91, avg:  837.35, max:  970.74, mdev:   46.79, cnt:  20
                  CSharp: top:  828.85, min:  819.36, avg:  843.39, max:  905.66, mdev:   19.79, cnt:  20
                    Dart: top:  843.20, min:  829.84, avg:  861.74, max:  949.99, mdev:   27.52, cnt:  20
                   Scala: top:  944.85, min:  897.81, avg:  996.39, max: 1122.12, mdev: 4186.68, cnt:  20
                  Elixir: top: 1072.99, min: 1054.52, avg: 1096.13, max: 1242.46, mdev: 4186.40, cnt:  20
           Bash_parallel: top: 1163.78, min: 1133.18, avg: 1219.09, max: 1340.50, mdev: 4186.69, cnt:  20
              POSIX_dash: top: 1393.27, min: 1370.19, avg: 1412.92, max: 1461.04, mdev: 4074.64, cnt:  20
                       R: top: 1475.58, min: 1458.35, avg: 1498.45, max: 1583.44, mdev: 4074.68, cnt:  20
              POSIX_bash: top: 1563.31, min: 1552.28, avg: 1574.53, max: 1605.96, mdev: 4074.59, cnt:  20
               POSIX_zsh: top: 1593.08, min: 1578.51, avg: 1620.55, max: 1719.31, mdev: 4062.81, cnt:  19
                    Bash: top: 2350.38, min: 2223.25, avg: 2506.19, max: 2867.53, mdev: 3579.59, cnt:  13
              PowerShell: top: 3695.72, min: 3680.86, avg: 3755.14, max: 3893.89, mdev: 2148.64, cnt:   8
               OCaml_lwt: FAILED with No such file or directory (os error 2)
           Ruby_rubinius: FAILED with No such file or directory (os error 2)

Java is Oracle JDK. Ruby_rubinius is not included because no packages available for Arch Linux. OCaml_lwt one is broken at the time of running the benchmark.

More Repositories

1

morerssplz

Convert other article sources to RSS feeds
Python
402
star
2

nvchecker

New version checker for software releases
Python
370
star
3

colorizer

A Vim plugin to colorize all text in the form #rrggbb or #rgb.
Vim Script
336
star
4

dotvim

My vim config
Vim Script
274
star
5

pssh

Parallel SSH Tools
Python
262
star
6

luoxu

A Telegram userbot to index Chinese and Japanese group contents.
Python
246
star
7

fcitx.vim

keep and restore fcitx state when leaving/re-entering insert mode
Python
234
star
8

winterpy

My python scripts started in winter.
Python
218
star
9

myawesomerc

My Awesome WM config files
Lua
84
star
10

dotzsh

My zsh config
Shell
56
star
11

search-and-view

Tools to make searching and viewing easy.
Python
47
star
12

xmpptalk

An XMPP bot to make a chatroom
Python
46
star
13

telegram-cache-decryption

Decrypt the media cache of Telegram Desktop
Python
46
star
14

capture-dns

A simple program to capture and show DNS queries
Rust
41
star
15

wait-online

Wait until we're connected to the Internet
Python
41
star
16

dotconfig

~/.config
Lua
40
star
17

dnssnoop

show which process did what DNS queries
Python
34
star
18

stdoutisatty

Make programs think their stdout is a tty / terminal.
C
34
star
19

ncdu-diff

ncdu fork that can compare and diff results
C
27
star
20

taskmaid

A D-Bus task API for Wayland
Rust
25
star
21

dpms-off

Turn off monitors to save power (for Wayland)
Rust
25
star
22

remotebrowser

open URLs from Windows virtual machines in the host system
Rust
24
star
23

openredir

redirect file open operations via LD_PRELOAD
C
24
star
24

luoxu-web

A web frontend for luoxu.
Svelte
23
star
25

2bbcode

A set of custom Pandoc writers for converting to BBCode.
Lua
23
star
26

abp-rules

My list of Adblock Plus rules, mainly for China websites
22
star
27

gaetalk

A chatroom application run on Google App Engine
Python
22
star
28

userscripts

My user scripts
JavaScript
21
star
29

cgtree

List cgroups info in a tree
Python
21
star
30

swapview

A simple program to view processes' swap usage on Linux.
Rust
20
star
31

archrepo2

Arch Linux repository manager
Python
19
star
32

monitor-control

The fastest way to get / set DDC values for a monitor
Rust
16
star
33

gm-github-tweaks

Tweak GitHub to make it great again.
CSS
16
star
34

udt_py

Python UDT
C++
15
star
35

ircbindxmpp

IRC <-> XMPP bidirectional connection
Python
14
star
36

compare-env

Compare the given environment variable value across all the processes
Rust
14
star
37

chinese-num

A Rust librrary to convert a decimal number to its Chinese form
Rust
13
star
38

spamfightbot

Another Telegram anti-spam bot without disturbance.
Python
13
star
39

fiemap-rs

FIEMAP library and tools for Rust
Rust
12
star
40

tornadochat

A web chatroom using tornado
Python
12
star
41

walkdir-test

a simple and naïve test to see which implementations of directory traversing is faster
Makefile
11
star
42

copy-link-address

Firefox addon to Copy Link Address with accesskey "a"
JavaScript
11
star
43

bluekeyslistener

Listen to bluetooth headphone keys (Linux only)
Rust
10
star
44

mozlz4-tool

A tool to process mozlz4 files
Rust
9
star
45

rpysh

Remote Python shell, for Linux Pythoners coping with Windows.
Python
8
star
46

bookmarked-search

Firefox addon to search the selected text using a search engine from your bookmarked search engines.
JavaScript
8
star
47

gdu-diff

Use gdu to diff and compare directory usages
Python
8
star
48

myhaskells

Haskell programs writing while learning
Haskell
7
star
49

paddleocr-web

A simple PaddleOCR web frontend.
Svelte
7
star
50

accurate-time

Show accurate time in tmux status
Rust
6
star
51

fcitx-lua-scripts

Lua
6
star
52

uniclip

Unify the clipboard operations for X11 and Wayland
Rust
6
star
53

paddleocr-service

Run PaddleOCR as a systemd service.
Shell
6
star
54

paperlike-i2c

i2c program for Dasung Paperlike HD e-ink monitors
Rust
6
star
55

HTTPSEverywhereUserRules

My personal HTTPSEverywhere rules
5
star
56

socat

socat - Multipurpose relay (cloned from git://repo.or.cz/socat.git) http://www.dest-unreach.org/socat/
C
5
star
57

cjk-align

Align CJK and emoji characters correctly on terminals
Rust
5
star
58

vim-foldtree

Fold ASCII tree graphs in Vim
Rust
5
star
59

fcitx-mb

A tool for interactively viewing and modifying fcitx's code tables.
Python
5
star
60

git-linked

git logs with hyperlinks
Python
5
star
61

website-styles

My custom styles for some websites (stylus)
CSS
4
star
62

https-speed

Show HTTPS speed in a terminal
Rust
4
star
63

tailf.vim

asynchronous "tail -f" and other shell commands in Vim 8
Vim Script
4
star
64

simplehist

A simple program to show a histogram on the terminal.
Rust
4
star
65

viewhtmlmsg

View an HTML email message in a browser (for text MUAs like mutt)
Python
4
star
66

android-dedupefs

A filesystem for reading Android dedupe backup
C
4
star
67

filequeue

send logs to Kafka, using the log file like a queue, without rotation.
Rust
4
star
68

fcitx5-dictsync

A tool to synchronize fcitx5 tabledict.
Rust
4
star
69

text-reflow-we

Firefox Android addon to allow click events to reflow text of that tag to fit screen width
JavaScript
3
star
70

srcipfix

fix source IP for UDP packets with netfilter_queue
Rust
3
star
71

roll-it-back

A command-line tool to rollback a possibly-nested btrfs subvolume to a snapshot
Rust
3
star
72

fetchtitle

Asynchronized URL information retriever
Python
3
star
73

cf-pop

Which Cloudflare® datacenter am I visiting? (Firefox addon)
JavaScript
3
star
74

imagestamp

add a stamp / watermark to a couple of images, at a chosen position for each
C
3
star
75

rust-signalbool

A simple crate to catch signals and set a boolean flag for later use.
Rust
3
star
76

mc2tg

A bot to synchronize messages from minecraft server to Telegram and back
Python
3
star
77

lilydjwg.github.io

HTML
2
star
78

x.rs

Extract various archive formats to standalone directory.
Rust
2
star
79

reorder-extensions

Reorder Firefox's extension menu with ease (see https://bugzilla.mozilla.org/show_bug.cgi?id=1831782)
Svelte
2
star
80

fcitx5-paste-primary

Fcitx Addon to Paste Primary selection with Keyboard
C++
2
star
81

open-noatime

Hook `open` and `open64` libc calls to avoid updating atimes while searching or the like.
Rust
2
star
82

fcitx5-tabledict

A tool to manipulate fcitx5 tabledict.
Rust
2
star
83

drop-serverhello

Drop ServerHello with netfilter_queue. For testing bug 1718719 of Firefox.
Rust
2
star
84

expiringdict-rs

A dict / HashMap whose items expire over time
Rust
2
star
85

multimc-bin-pkgbuild

Repackage multimc for Arch Linux in a distribution way
Shell
1
star
86

rust-tokio-anyfd

Use any suitable file descriptor with tokio
Rust
1
star
87

my-trime

My customizations for trime
Shell
1
star
88

pyparsing_fork

My fork for pyparsing, on *GitHub*
Python
1
star
89

pid_children

A simple program outputs descendant process ids for each pid given on the command line
Rust
1
star
90

extsort-lily

An efficient external sort library for Rust
Rust
1
star
91

journal-usage

Analyze systemd journal usage by unit or by date
Rust
1
star
92

netctl-lily

Profile based systemd network management. lilydjwg's fork.
Shell
1
star
93

transgender-pride-3

Transgender Pride 3 is a Firefox theme that changes itself based on system theme kind.
Python
1
star
94

archutils

My personal scripts for Arch Linux
Python
1
star
95

sys-stat

System Statistics Collector
Rust
1
star