]> gitweb.factorcode.org Git - factor.git/blob - basis/system-info/system-info.factor
Factor source files should not be executable
[factor.git] / basis / system-info / system-info.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.syntax kernel math prettyprint io math.parser
4 combinators vocabs.loader system-info.backend system ;
5 IN: system-info
6
7 : write-unit ( x n str -- )
8     [ 2^ /f number>string write bl ] [ write ] bi* ;
9
10 : kb ( x -- ) 10 "kB" write-unit ;
11 : megs ( x -- ) 20 "MB" write-unit ;
12 : gigs ( x -- ) 30 "GB" write-unit ;
13 : ghz ( x -- ) 1000000000 /f number>string write bl "GHz" write ;
14
15 << {
16     { [ os windows? ] [ "system-info.windows" ] }
17     { [ os linux? ] [ "system-info.linux" ] }
18     { [ os macosx? ] [ "system-info.macosx" ] }
19     [ f ]
20 } cond [ require ] when* >>
21
22 : system-report. ( -- )
23     "CPUs: " write cpus number>string write nl
24     "CPU Speed: " write cpu-mhz ghz nl
25     "Physical RAM: " write physical-mem megs nl ;