factor/extra/system-info/system-info.factor

26 lines
829 B
Factor
Raw Normal View History

2008-12-06 23:58:19 -05:00
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
2008-04-03 02:48:29 -04:00
USING: alien.syntax kernel math prettyprint io math.parser
2008-12-06 23:58:19 -05:00
combinators vocabs.loader system-info.backend system ;
IN: system-info
2007-09-20 18:09:08 -04:00
2008-04-03 02:48:29 -04:00
: write-unit ( x n str -- )
2008-04-04 00:35:57 -04:00
[ 2^ /f number>string write bl ] [ write ] bi* ;
2008-04-03 02:48:29 -04:00
: kb ( x -- ) 10 "kB" write-unit ;
: megs ( x -- ) 20 "MB" write-unit ;
: gigs ( x -- ) 30 "GB" write-unit ;
2008-04-04 00:35:57 -04:00
: ghz ( x -- ) 1000000000 /f number>string write bl "GHz" write ;
2007-09-20 18:09:08 -04:00
2008-04-02 20:23:37 -04:00
<< {
2008-12-06 23:58:19 -05:00
{ [ os windows? ] [ "system-info.windows" ] }
{ [ os linux? ] [ "system-info.linux" ] }
{ [ os macosx? ] [ "system-info.macosx" ] }
2008-04-11 13:55:57 -04:00
[ f ]
} cond [ require ] when* >>
2008-04-03 02:48:29 -04:00
2008-12-06 23:58:19 -05:00
: system-report. ( -- )
2008-04-03 02:48:29 -04:00
"CPUs: " write cpus number>string write nl
2008-04-04 00:35:57 -04:00
"CPU Speed: " write cpu-mhz ghz nl
2008-04-03 02:48:29 -04:00
"Physical RAM: " write physical-mem megs nl ;