From 814f40d6432724d36cae8d2f8bfa0cf7b28405bb Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Tue, 3 Aug 2021 19:02:12 +0800 Subject: [PATCH] align total formats --- Bash/swapview.sh | 2 +- Bash_parallel/swapview.sh | 2 +- C++11/swapview.cc | 2 +- C++14/swapview.cpp | 2 +- C++14_boost/swapview.cpp | 2 +- C++17/swapview.cpp | 2 +- C++98/swapview.cpp | 2 +- C/swapview.c | 2 +- CSharp/SwapView.cs | 2 +- ChezScheme/swapview.ss | 2 +- Chicken/swapview.scm | 2 +- CoffeeScript/swapview.coffee | 4 +- CoffeeScript_parallel/swapview.coffee | 4 +- CommonLisp_old/swapview.lisp | 4 +- CommonLisp_opt/swapview.lisp | 4 +- Crystal/common.cr | 2 +- Cython/swapview.pyx | 2 +- D/swapview.d | 2 +- D_parallel/swapview.d | 2 +- Dart/swapview.dart | 2 +- Elixir/swapview.exs | 2 +- Erlang/swapview.erl | 2 +- FreePascal/swapview.pas | 2 +- Go/swapview.go | 2 +- Go_goroutine/swapview.go | 2 +- Guile/swapview.scm | 2 +- Haskell/swapview.hs | 2 +- Haskell_parallel/swapview.hs | 2 +- Java/SwapView.java | 2 +- Julia/swapview.jl | 2 +- Lua/swapview.lua | 2 +- Nim/swapview.nim | 2 +- NodeJS/swapview.js | 2 +- NodeJS_async/swapview.js | 2 +- NodeJS_cluster/swapview.js | 2 +- OCaml/swapview.ml | 2 +- PHP/swapview.php | 2 +- POSIX_shell/swapview.sh | 2 +- Perl/swapview.pl | 2 +- PowerShell/swapview.ps1 | 2 +- Python/swapview.py | 2 +- Python3_bytes/swapview.py | 2 +- Python_mp/swapview.py | 2 +- R/swapview.r | 2 +- Racket/swapview.rkt | 2 +- Ruby/swapview.rb | 2 +- Rust/swapview.rs | 4 +- Rust_parallel/.swapview/Cargo.lock | 127 ++++++++++++-------------- Rust_parallel/swapview.rs | 4 +- Scala/swapview.scala | 2 +- Tcl/swapview.tcl | 2 +- Vala/swapview.vala | 2 +- benchmark/Cargo.lock | 20 ++-- broken/OCaml_lwt/swapview.ml | 2 +- 54 files changed, 126 insertions(+), 137 deletions(-) diff --git a/Bash/swapview.sh b/Bash/swapview.sh index 33891d7..1f2c0d6 100755 --- a/Bash/swapview.sh +++ b/Bash/swapview.sh @@ -39,7 +39,7 @@ getSwap(){ printf '%7s %9s %s\n' "$pid" "$(filesize $((swap*1024)))" "$command" fi || continue done; printf '%s\n' $((sum * 1024)) > $sumfile) | sort -k2 -h - printf "Total: %8s\n" "$(filesize "$(<$sumfile)")" + printf "Total: %10s\n" "$(filesize "$(<$sumfile)")" rm "$sumfile" } diff --git a/Bash_parallel/swapview.sh b/Bash_parallel/swapview.sh index 3ce45a3..9d00ccc 100755 --- a/Bash_parallel/swapview.sh +++ b/Bash_parallel/swapview.sh @@ -60,7 +60,7 @@ function getSwap(){ sumsize=0 fi total=$(filesize $(( $(echo "$sumsize" | bc) *1024))) - printf "Total: %8s\n" "$total" + printf "Total: %10s\n" "$total" rm "$sumfile" } diff --git a/C++11/swapview.cc b/C++11/swapview.cc index db1d521..cc015d3 100644 --- a/C++11/swapview.cc +++ b/C++11/swapview.cc @@ -125,6 +125,6 @@ int main(){ total += x.size; } auto size = output_size(total); - std::printf("Total: %8s\n", size.c_str()); + std::printf("Total: %10s\n", size.c_str()); return 0; } diff --git a/C++14/swapview.cpp b/C++14/swapview.cpp index fb25323..8b6f534 100644 --- a/C++14/swapview.cpp +++ b/C++14/swapview.cpp @@ -86,6 +86,6 @@ int main(int argc, char * argv[]){ << "\n"; t+=get<1>(item); } - cout<<"Total:"<(item) % filesize(get<1>(item)) % get<2>(item) << "\n"; t+=get<1>(item); } - cout<< boost::format("Total:%|9|") % filesize(t)<<"\n"; + cout<< boost::format("Total: %|10|") % filesize(t)<<"\n"; return 0; } diff --git a/C++17/swapview.cpp b/C++17/swapview.cpp index 705c0ce..2088f18 100644 --- a/C++17/swapview.cpp +++ b/C++17/swapview.cpp @@ -68,5 +68,5 @@ int main() { << std::setw(0) << cmd << '\n'; total += swp; } - std::cout << "Total:" << std::setw(9) << filesize(total) << std::endl; + std::cout << "Total: " << std::setw(10) << filesize(total) << std::endl; } diff --git a/C++98/swapview.cpp b/C++98/swapview.cpp index c69e29f..d8fa1a5 100644 --- a/C++98/swapview.cpp +++ b/C++98/swapview.cpp @@ -137,6 +137,6 @@ int main(int argc, char * argv[]){ format_print(*itr); t += itr->size; } - cout<<"Total:"< console.log str console.log [ - 'Total:' - fillLength 9, (formatSize0 (res.reduce addSecond, 0)) + 'Total: ' + fillLength 10, (formatSize0 (res.reduce addSecond, 0)) ].join('') diff --git a/CoffeeScript_parallel/swapview.coffee b/CoffeeScript_parallel/swapview.coffee index 9bf8207..ddfd49b 100755 --- a/CoffeeScript_parallel/swapview.coffee +++ b/CoffeeScript_parallel/swapview.coffee @@ -77,6 +77,6 @@ prettyPrint = (res) -> console.log str console.log [ - 'Total:' - fillLength 9, (formatSize0 (res.reduce addSecond, 0)) + 'Total: ' + fillLength 10, (formatSize0 (res.reduce addSecond, 0)) ].join('') diff --git a/CommonLisp_old/swapview.lisp b/CommonLisp_old/swapview.lisp index 6142e54..354ba5f 100755 --- a/CommonLisp_old/swapview.lisp +++ b/CommonLisp_old/swapview.lisp @@ -29,13 +29,13 @@ (defun print-result (list) "Print the result in list, which item: (id swap cmdline)" - (let ((format-string "~7@A~7T~8@A~8T~A~%")) + (let ((format-string "~7@A~7T~9@A~9T~A~%")) (progn (format t format-string "PID" "SWAP" "COMMAND") (loop for item in list summing (second item) into total do (format t format-string (first item) (convert-size (second item)) (third item)) - finally (format t "Total: ~A~%" (convert-size total)))))) + finally (format t "Total: ~10@A~%" (convert-size total)))))) (defun get-process-id (path) "Return process id from the path" diff --git a/CommonLisp_opt/swapview.lisp b/CommonLisp_opt/swapview.lisp index aa94cc9..6993206 100644 --- a/CommonLisp_opt/swapview.lisp +++ b/CommonLisp_opt/swapview.lisp @@ -32,12 +32,12 @@ (defun print-result (lis) "Print the result in list, which item: (id swap cmdline)" - (let ((format-string "~7@A~7T~8@A~8T~A~%")) + (let ((format-string "~7@A~7T~9@A~9T~A~%")) (format t format-string "PID" "SWAP" "COMMAND") (loop for item in lis summing (second item) into total do (format t format-string (first item) (convert-size (second item)) (third item)) - finally (format t "Total: ~A~%" (convert-size total))))) + finally (format t "Total: ~10@A~%" (convert-size total))))) (defun get-process-id (path) "Return process id from the path" diff --git a/Crystal/common.cr b/Crystal/common.cr index 27129e1..a6ee081 100644 --- a/Crystal/common.cr +++ b/Crystal/common.cr @@ -2,7 +2,7 @@ module SwapView extend self FORMAT = "%7s %9s %s" - TOTALFMT = "Total: %8s" + TOTALFMT = "Total: %10s" SWAP = "Swap: " def filesize(size) diff --git a/Cython/swapview.pyx b/Cython/swapview.pyx index 47202ce..0afdfff 100755 --- a/Cython/swapview.pyx +++ b/Cython/swapview.pyx @@ -11,7 +11,7 @@ from libc.string cimport strncmp, memmove import os format = "%7s %9s %s" -totalFmt = "Total: %8s" +totalFmt = "Total: %10s" cdef int find_size(char *s): cdef char *s_tmp = s + 5 diff --git a/D/swapview.d b/D/swapview.d index 66cdad4..6ad876f 100755 --- a/D/swapview.d +++ b/D/swapview.d @@ -82,5 +82,5 @@ void main(){ total += item.size; writeln(format(m , item.pid, filesize(item.size), item.comm)); } - writeln(format("Total: %8s", filesize(total))); + writeln(format("Total: %10s", filesize(total))); } diff --git a/D_parallel/swapview.d b/D_parallel/swapview.d index 105117c..75e55d9 100755 --- a/D_parallel/swapview.d +++ b/D_parallel/swapview.d @@ -83,7 +83,7 @@ void main(){ total += item.size; writeln(format(m, item.pid, filesize(item.size), item.comm)); } - writeln(format("Total: %8s", filesize(total))); + writeln(format("Total: %10s", filesize(total))); } // vim: set et ts=4 sw=4 diff --git a/Dart/swapview.dart b/Dart/swapview.dart index 3e0f391..93d0127 100644 --- a/Dart/swapview.dart +++ b/Dart/swapview.dart @@ -65,5 +65,5 @@ main() { print( "${result.pid.padLeft(7)} ${toHumanReadable(result.swap).padLeft(9)} ${result.cmdline}"); } - print("Total: ${toHumanReadable(total).padLeft(8)}"); + print("Total: ${toHumanReadable(total).padLeft(10)}"); } diff --git a/Elixir/swapview.exs b/Elixir/swapview.exs index 25da497..b982ae2 100755 --- a/Elixir/swapview.exs +++ b/Elixir/swapview.exs @@ -43,7 +43,7 @@ defmodule SwapView do format {pid, size |> filesize, comm} end) total = result |> Enum.map(fn {_, size, _} -> size end) |> Enum.sum |> filesize - IO.puts "Total: #{total |> String.pad_leading(8)}" + IO.puts "Total: #{total |> String.pad_leading(10)}" end end diff --git a/Erlang/swapview.erl b/Erlang/swapview.erl index 7eb3032..6828de7 100644 --- a/Erlang/swapview.erl +++ b/Erlang/swapview.erl @@ -33,7 +33,7 @@ swap_print() -> io:format("~7s ~9s ~s~n", ["PID", "SWAP", "COMMAND"]), [io:format("~7s ~9s ~s~n", [Pid, filesize(Size), Cmd]) || {Pid, Cmd, Size} <- Ret], Total = lists:sum([Size || {_,_,Size} <- Ret]), - io:format("Total: ~8s~n", [filesize(Total)]). + io:format("Total: ~10s~n", [filesize(Total)]). getswap() -> {ok, F} = file:list_dir_all("/proc"), diff --git a/FreePascal/swapview.pas b/FreePascal/swapview.pas index 6ad9343..ef2df9d 100644 --- a/FreePascal/swapview.pas +++ b/FreePascal/swapview.pas @@ -181,5 +181,5 @@ t := t + results[i].size; WriteLn(Format('%7D %9S %S', [results[i].pid, filesize(results[i].size), results[i].comm])); End; - WriteLn(Format('Total: %8S', [filesize(t)])); + WriteLn(Format('Total: %10S', [filesize(t)])); End. diff --git a/Go/swapview.go b/Go/swapview.go index d598fbb..7a326ea 100644 --- a/Go/swapview.go +++ b/Go/swapview.go @@ -36,7 +36,7 @@ func main() { fmt.Printf("%7d %9s %s\n", v.Pid, FormatSize(v.Size), v.Comm) total += v.Size } - fmt.Printf("Total: %8s\n", FormatSize(total)) + fmt.Printf("Total: %10s\n", FormatSize(total)) } func GetInfos() (list []Info) { diff --git a/Go_goroutine/swapview.go b/Go_goroutine/swapview.go index 2876456..00939df 100644 --- a/Go_goroutine/swapview.go +++ b/Go_goroutine/swapview.go @@ -38,7 +38,7 @@ func main() { fmt.Printf("%7d %9s %s\n", v.Pid, FormatSize(v.Size), v.Comm) total += v.Size } - fmt.Printf("Total: %8s\n", FormatSize(total)) + fmt.Printf("Total: %10s\n", FormatSize(total)) } func GetInfos() (list []Info) { diff --git a/Guile/swapview.scm b/Guile/swapview.scm index 30b99e3..1af1995 100755 --- a/Guile/swapview.scm +++ b/Guile/swapview.scm @@ -53,7 +53,7 @@ (format #t FORMATSTR "PID" "SWAP" "COMMAND") (let lp((next results) (total 0)) (cond - ((null? next) (format #t "Total: ~8@a~%" (filesize total))) + ((null? next) (format #t "Total: ~10@a~%" (filesize total))) (else (let ((item (car next))) (format #t FORMATSTR diff --git a/Haskell/swapview.hs b/Haskell/swapview.hs index 18b4f0e..b5874eb 100644 --- a/Haskell/swapview.hs +++ b/Haskell/swapview.hs @@ -17,7 +17,7 @@ type Pid = Int format = "%7d %9s %s" formatHead = "%7s %9s %s" -totalFmt = "Total: %8s" +totalFmt = "Total: %10s" firstLine = printf formatHead ("PID" :: Text) ("SWAP" :: Text) ("COMMAND" :: Text) main = do diff --git a/Haskell_parallel/swapview.hs b/Haskell_parallel/swapview.hs index c339c82..4c27b14 100644 --- a/Haskell_parallel/swapview.hs +++ b/Haskell_parallel/swapview.hs @@ -18,7 +18,7 @@ type Pid = Int format = "%7d %9s %s" formatHead = "%7s %9s %s" -totalFmt = "Total: %8s" +totalFmt = "Total: %10s" firstLine = printf formatHead ("PID" :: Text) ("SWAP" :: Text) ("COMMAND" :: Text) main = do diff --git a/Java/SwapView.java b/Java/SwapView.java index 97aa78a..a5b239e 100644 --- a/Java/SwapView.java +++ b/Java/SwapView.java @@ -70,6 +70,6 @@ public static void main (String [] argv){ System.out.printf("%7d %9s %s\n", s.pid, filesize(s.size), s.comm); t += s.size; } - System.out.printf("Total: %8s\n", filesize(t)); + System.out.printf("Total: %10s\n", filesize(t)); } } diff --git a/Julia/swapview.jl b/Julia/swapview.jl index 9e40523..6bb0963 100755 --- a/Julia/swapview.jl +++ b/Julia/swapview.jl @@ -47,7 +47,7 @@ function main() @inbounds for (pid, swap, comm) in results @printf("%7s %9s %s\n", pid, filesizeKB(swap), comm) end - @printf("Total: %8s\n", isempty(results) ? "0B" : + @printf("Total: %10s\n", isempty(results) ? "0B" : filesizeKB(sum((x) -> x[2], results))) end diff --git a/Lua/swapview.lua b/Lua/swapview.lua index 2675468..88b5693 100755 --- a/Lua/swapview.lua +++ b/Lua/swapview.lua @@ -80,7 +80,7 @@ function getSwap() end local fmt = "%7s %9s %s" -local totalFmt = "Total: %8s" +local totalFmt = "Total: %10s" local results = getSwap() local sum = 0 print(format(fmt, 'PID', 'SWAP', 'COMMAND')) diff --git a/Nim/swapview.nim b/Nim/swapview.nim index bcd1437..fc9de61 100644 --- a/Nim/swapview.nim +++ b/Nim/swapview.nim @@ -71,4 +71,4 @@ for i in infos: echo i t += i.swap var total = filesize(t) -echo "Total: " & spaces(max(0, 8 - total.len)) & total +echo "Total: " & spaces(max(0, 10 - total.len)) & total diff --git a/NodeJS/swapview.js b/NodeJS/swapview.js index 067cce4..04fb781 100755 --- a/NodeJS/swapview.js +++ b/NodeJS/swapview.js @@ -65,4 +65,4 @@ results.forEach(s => { t += s[1] }) -console.log(sprintf("Total: %8s", filesize(t))) +console.log(sprintf("Total: %10s", filesize(t))) diff --git a/NodeJS_async/swapview.js b/NodeJS_async/swapview.js index 3534557..dc59e7d 100755 --- a/NodeJS_async/swapview.js +++ b/NodeJS_async/swapview.js @@ -74,5 +74,5 @@ getSwap(function(err, results){ console.log(sprintf("%7s %9s %s", s[0], filesize(s[1]), s[2])); t += s[1]; }); - console.log(sprintf("Total: %8s", filesize(t))); + console.log(sprintf("Total: %10s", filesize(t))); }); diff --git a/NodeJS_cluster/swapview.js b/NodeJS_cluster/swapview.js index a4a6b26..efbfc5f 100644 --- a/NodeJS_cluster/swapview.js +++ b/NodeJS_cluster/swapview.js @@ -74,7 +74,7 @@ if (cluster.isMaster) { console.log(sprintf('%7s %9s %s', s[0], filesize(s[1]), s[2])); t += s[1]; }); - console.log(sprintf('Total: %8s', filesize(t))); + console.log(sprintf('Total: %10s', filesize(t))); } // fork workers diff --git a/OCaml/swapview.ml b/OCaml/swapview.ml index a2ffec8..0803d27 100644 --- a/OCaml/swapview.ml +++ b/OCaml/swapview.ml @@ -64,7 +64,7 @@ let get_swaps () : swap_t list = let main = let print' = Printf.printf "%7s %9s %s\n" in let print_swap (pid, swap, comm) = print' pid (filesize swap) comm in - let print_total total = Printf.printf "Total: %8s\n" (filesize total) in + let print_total total = Printf.printf "Total: %10s\n" (filesize total) in let swaps = get_swaps () in let total = List.fold_left (fun acc (_, x, _) -> acc + x) 0 swaps in diff --git a/PHP/swapview.php b/PHP/swapview.php index 60e7fae..83a21f0 100755 --- a/PHP/swapview.php +++ b/PHP/swapview.php @@ -81,4 +81,4 @@ function getSwap() $totalSize += $result[1]; } -printf("Total: %8s" . PHP_EOL, renderSize($totalSize)); +printf("Total: %10s" . PHP_EOL, renderSize($totalSize)); diff --git a/POSIX_shell/swapview.sh b/POSIX_shell/swapview.sh index 39b6f37..2551ee4 100755 --- a/POSIX_shell/swapview.sh +++ b/POSIX_shell/swapview.sh @@ -59,7 +59,7 @@ main() { printf(printf_format, $1, convert_file_size_from_kB($2), join_field(3, NF, " ")) } END{ - printf("Total: %s\n", convert_file_size_from_kB(total)) + printf("Total: %10s\n", convert_file_size_from_kB(total)) }' } diff --git a/Perl/swapview.pl b/Perl/swapview.pl index d1ed9db..4bdbb8d 100755 --- a/Perl/swapview.pl +++ b/Perl/swapview.pl @@ -74,7 +74,7 @@ sub main { $total_swap_size += $result->{'swap'}; printf $printf_format, $result->{'pid'}, convert_file_size_from_kB( $result->{'swap'} ), $result->{'cmd'}; } - printf qq{Total: %8s\n}, convert_file_size_from_kB( $total_swap_size ); + printf qq{Total: %10s\n}, convert_file_size_from_kB( $total_swap_size ); } main diff --git a/PowerShell/swapview.ps1 b/PowerShell/swapview.ps1 index 6037899..d999ef7 100755 --- a/PowerShell/swapview.ps1 +++ b/PowerShell/swapview.ps1 @@ -36,4 +36,4 @@ Get-ChildItem /proc | Where-Object { $_.Name -match '^[0-9]+$' } | ForEach-Objec Write-Output ("{0,7} {1,9} {2}" -f $_.Pid, (FileSize $_.Size), $_.Cmd) } -Write-Output ("Total: {0,8}" -f (FileSize $total)) +Write-Output ("Total: {0,10}" -f (FileSize $total)) diff --git a/Python/swapview.py b/Python/swapview.py index 2311950..203b07c 100755 --- a/Python/swapview.py +++ b/Python/swapview.py @@ -7,7 +7,7 @@ import re format = "%7s %9s %s" -totalFmt = "Total: %8s" +totalFmt = "Total: %10s" def filesize(size): units = 'KMGT' diff --git a/Python3_bytes/swapview.py b/Python3_bytes/swapview.py index cd51a80..f56e03b 100755 --- a/Python3_bytes/swapview.py +++ b/Python3_bytes/swapview.py @@ -3,7 +3,7 @@ import os format = "%7s %9s %s" -totalFmt = "Total: %8s" +totalFmt = "Total: %10s" def filesize(size): units = 'KMGT' diff --git a/Python_mp/swapview.py b/Python_mp/swapview.py index 29fb84c..0372f23 100755 --- a/Python_mp/swapview.py +++ b/Python_mp/swapview.py @@ -7,7 +7,7 @@ import os format = "%7s %9s %s" -totalFmt = "Total: %8s" +totalFmt = "Total: %10s" def filesize(size): units = 'KMGT' diff --git a/R/swapview.r b/R/swapview.r index b118c97..8f859dd 100755 --- a/R/swapview.r +++ b/R/swapview.r @@ -64,4 +64,4 @@ for(i in 1:nrow(result)){ t = t + size } } -write(sprintf("Total: %8s", filesize(t)), stdout()) +write(sprintf("Total: %10s", filesize(t)), stdout()) diff --git a/Racket/swapview.rkt b/Racket/swapview.rkt index 57bd5dd..b3b84ac 100755 --- a/Racket/swapview.rkt +++ b/Racket/swapview.rkt @@ -18,7 +18,7 @@ (define (total n) (begin (display "Total: ") - (display (~a n #:min-width 8)) + (display (~a n #:min-width 10)) (newline))) (define (strinit s) diff --git a/Ruby/swapview.rb b/Ruby/swapview.rb index 014aee6..c60d990 100755 --- a/Ruby/swapview.rb +++ b/Ruby/swapview.rb @@ -4,7 +4,7 @@ # for Ruby 2.4+ FORMAT = '%7s %9s %s' -TOTALFMT = 'Total: %8s' +TOTALFMT = 'Total: %10s' UNITS = %w[B KiB MiB GiB TiB].freeze def filesize(size) diff --git a/Rust/swapview.rs b/Rust/swapview.rs index 613162a..805229f 100644 --- a/Rust/swapview.rs +++ b/Rust/swapview.rs @@ -82,8 +82,6 @@ fn get_swap() -> Vec<(usize, isize, String)> { } fn main() { - // let format = "{:>5} {:>9} {}"; - // let totalFmt = "Total: {:8}"; let mut swapinfo = get_swap(); swapinfo.sort_unstable_by(|&(_, a, _), &(_, b, _)| { a.cmp(&b) }); @@ -93,7 +91,7 @@ fn main() { total += swap; println!("{:>7} {:>9} {}", pid, filesize(swap), comm); } - println!("Total: {:>8}", filesize(total)); + println!("Total: {:>10}", filesize(total)); } // vim: se sw=2: diff --git a/Rust_parallel/.swapview/Cargo.lock b/Rust_parallel/.swapview/Cargo.lock index 000cb9f..44f7369 100644 --- a/Rust_parallel/.swapview/Cargo.lock +++ b/Rust_parallel/.swapview/Cargo.lock @@ -1,153 +1,144 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "autocfg" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "cfg-if" -version = "0.1.10" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "crossbeam-deque" -version = "0.7.3" +name = "crossbeam-channel" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ - "crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "crossbeam-utils", ] [[package]] -name = "crossbeam-epoch" -version = "0.8.2" +name = "crossbeam-deque" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", ] [[package]] -name = "crossbeam-queue" -version = "0.2.3" +name = "crossbeam-epoch" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cfg-if", + "lazy_static", ] [[package]] name = "either" -version = "1.5.3" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "hermit-abi" -version = "0.1.15" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ - "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.72" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "maybe-uninit" -version = "2.0.0" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" [[package]] name = "memoffset" -version = "0.5.5" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc14fc54a812b4472b4113facc3e44d099fbc0ea2ce0551fa5c703f8edfbfd38" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", ] [[package]] name = "num_cpus" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ - "hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi", + "libc", ] [[package]] name = "rayon" -version = "1.3.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", ] [[package]] name = "rayon-core" -version = "1.7.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", ] [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "swapview" version = "0.0.1" dependencies = [ - "rayon 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon", ] - -[metadata] -"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -"checksum crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -"checksum crossbeam-queue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -"checksum hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701" -"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" -"checksum memoffset 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" -"checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -"checksum rayon 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" -"checksum rayon-core 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" -"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" diff --git a/Rust_parallel/swapview.rs b/Rust_parallel/swapview.rs index fba8bcb..f4ca1c1 100644 --- a/Rust_parallel/swapview.rs +++ b/Rust_parallel/swapview.rs @@ -73,7 +73,7 @@ fn get_swap_for(pid: usize) -> isize { } fn get_swap() -> Vec<(usize, isize, String)> { - rayon::scope(|pool| { + rayon::in_place_scope(|pool| { let (tx, rx) = channel(); for d in read_dir("/proc").unwrap() { let tx = tx.clone(); @@ -106,7 +106,7 @@ fn main() { total += swap; println!("{:>7} {:>9} {}", pid, filesize(swap), comm); } - println!("Total: {:>8}", filesize(total)); + println!("Total: {:>10}", filesize(total)); } // vim: se sw=2: diff --git a/Scala/swapview.scala b/Scala/swapview.scala index e26b8e4..7af4ecf 100644 --- a/Scala/swapview.scala +++ b/Scala/swapview.scala @@ -55,5 +55,5 @@ object SwapView extends App { printf("%7d %9s %s\n", res.pid, swapview.filesize(res.size), res.comm) x += res.size } - printf("Total: %8s\n", swapview.filesize(x)) + printf("Total: %10s\n", swapview.filesize(x)) } diff --git a/Tcl/swapview.tcl b/Tcl/swapview.tcl index 9119587..70d3857 100755 --- a/Tcl/swapview.tcl +++ b/Tcl/swapview.tcl @@ -47,5 +47,5 @@ puts [format "%7s %9s %s" PID SWAP COMMAND] foreach i [lsort -integer -index 1 $all] { puts [format "%7s %9s %s" [lindex $i 0] [fileSize [lindex $i 1]] [lindex $i 2]] } -puts [format "Total: %8s" [fileSize $total]] +puts [format "Total: %10s" [fileSize $total]] diff --git a/Vala/swapview.vala b/Vala/swapview.vala index c5b9a87..f270081 100644 --- a/Vala/swapview.vala +++ b/Vala/swapview.vala @@ -73,6 +73,6 @@ static int main (string[] args){ stdout.printf("%7lld %9s %s\n", s.pid, filesize(s.size), s.comm); t += s.size; } - stdout.printf("Total: %8s\n", filesize(t)); + stdout.printf("Total: %10s\n", filesize(t)); return 0; } diff --git a/benchmark/Cargo.lock b/benchmark/Cargo.lock index 4629ead..48a28aa 100644 --- a/benchmark/Cargo.lock +++ b/benchmark/Cargo.lock @@ -1,32 +1,32 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "benchmark" version = "0.0.2" dependencies = [ - "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "glob", + "toml", ] [[package]] name = "glob" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "serde" -version = "1.0.104" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8" [[package]] name = "toml" -version = "0.5.5" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde", ] - -[metadata] -"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" -"checksum toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "01d1404644c8b12b16bfcffa4322403a91a451584daaaa7c28d3152e6cbc98cf" diff --git a/broken/OCaml_lwt/swapview.ml b/broken/OCaml_lwt/swapview.ml index 64e1a8f..afca067 100644 --- a/broken/OCaml_lwt/swapview.ml +++ b/broken/OCaml_lwt/swapview.ml @@ -64,7 +64,7 @@ let get_swaps () : swap_t list Lwt.t = let%lwt main = let print' = Lwt_io.printf "%7s %9s %s\n" in let print_swap (pid, swap, comm) = print' pid (filesize swap) comm in - let print_total total = Lwt_io.printf "Total: %8s\n" (filesize total) in + let print_total total = Lwt_io.printf "Total: %10s\n" (filesize total) in let%lwt swaps = get_swaps () in let total = List.fold_left (fun acc (_, x, _) -> acc + x) 0 swaps in