in reply to Re: time and mem usage of pgm
in thread time and mem usage of pgm

how is it possible to test in perl if the program is running on win or linux? In this way, the same program can be used on both system and if it is under linux, proc/stat will be used to measure time and mem and if it is win, your code.

Replies are listed 'Best First'.
Re^3: time and mem usage of pgm
by BrowserUk (Patriarch) on Mar 10, 2015 at 09:14 UTC
    how is it possible to test in perl if the program is running on win or linux?

    Simply:

    if( $^O eq 'MSWin32' ) { ## Do the windows thing } else { ## else do something else }

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

      Does this consider only 32-bits or 64-bit architecture, too?

        The documentation for this is both explicit and helpful - even going so far as to recommend a module for further tests.

      I don't know why I got the locale settings problem even if I don't add the proposed code:
      perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "en_US:en", LC_ALL = (unset), LC_PAPER = "fr_FR.UTF-8", LC_ADDRESS = "fr_FR.UTF-8", LC_MONETARY = "fr_FR.UTF-8", LC_NUMERIC = "fr_FR.UTF-8", LC_TELEPHONE = "fr_FR.UTF-8", LC_IDENTIFICATION = "fr_FR.UTF-8", LC_MEASUREMENT = "fr_FR.UTF-8", LC_TIME = "fr_FR.UTF-8", LC_NAME = "fr_FR.UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C").

        Looks to be a linux problem, which I know next to nothing about.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
        In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
Re^3: time and mem usage of pgm
by hippo (Archbishop) on Mar 10, 2015 at 09:53 UTC
Re^3: time and mem usage of pgm
by Anonymous Monk on Mar 10, 2015 at 09:29 UTC

    You don't need to test, if there is a tasklist.exe pslist.exe of memlist.exe, it doesn't matter what platform it is, their usage is probably the same on win32 and on linux :)

    Devel::CheckOS, Devel::AssertOS

      You don't need to test, if there is a tasklist.exe pslist.exe of memlist.exe, it doesn't matter what platform it is, their usage is probably the same on win32 and on linux :)

      tasklist.exe is an executable that ships as part of windows. Unlikely to be a linux version.

      And as far as I know, no *nix executables are named *.exe


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked