GithubHelp home page GithubHelp logo

tester's Introduction

Tester

This is a simple tool to execute a program on Windows and report its CPU and memory usage, or to optionally kill it if it takes too long. You can think of it as limited versions of Unix time and timeout rolled into one, with some memory usage tracking added on top.

Minimally, the tool just executes another program and reports its CPU and memory usage:

>tester testee
CPU time used: 15 ms
Memory used: 3 MB

If the command to execute contains spaces, it must be enclosed in quotes

>tester "testee command line options"
CPU time used: 15 ms
Memory used: 3 MB

I originally wrote this tool to help me evaluate solutions to programming assignments. To support batch scripting, the tool allows setting of CPU and memory usage limits and returns non-zero error codes when the limits are exceeded:

>tester -t 1000 cpu_hog_testee
CPU time used: 1500 / 1000 ms
Memory used: 3 MB
CPU time limit exceeded!
>echo %errorlevel%
3
>tester -m 10 memory_hog_testee
CPU time used: 15 ms
Memory used: 15 / 10 MB
Memory limit exceeded!
>echo %errorlevel%
4

The tool also kills the program after twice the time limit has elapsed in wall clock time, even when the program uses no CPU time (most likely blocking on input that's not there):

>tester -t 1000 idle_testee
Wall time limit exceeded!
Attempting to kill... OK
>echo %errorlevel%
3

The tool also returns an error code when the program under test fails or can't be executed at all:

>tester failing_testee
Process exit code: 5
>echo %errorlevel%
1

The tool can track CPU and memory usage of multithreaded programs, but not of programs spawning multiple processes. The latter case is detected and reported:

>tester forking_testee
Process forked!
>echo %errorlevel%
2

Recently I had a need for such a tool again and it seems to still work on current versions of Windows. I decided to upload it here in case it's useful for someone else as well. But keep in mind, this is not a sandbox for safely executing potentially malicious code!

Files

  • tester.c - source code of the tool
  • tester.exe - statically linked 64-bit executable of the tool in case you don't have a C compiler
  • test_time.c - a program that uses CPU time in multiple threads, to test time accounting
  • test_mem.c - a program that allocates some memory in multiple threads, to test memory accounting
  • test_idle.c - a program that idles without using CPU time
  • test_fork.c - a program that spawns a sub-process

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.