{"id":16838785,"url":"https://github.com/soimort/hit-and-run","last_synced_at":"2025-04-10T18:34:48.277Z","repository":{"id":29997794,"uuid":"33545283","full_name":"soimort/hit-and-run","owner":"soimort","description":"Handy tool for competitive programming","archived":false,"fork":false,"pushed_at":"2015-06-05T07:58:27.000Z","size":164,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T16:11:26.018Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soimort.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-07T13:37:43.000Z","updated_at":"2024-12-30T20:35:22.000Z","dependencies_parsed_at":"2022-09-01T15:32:10.538Z","dependency_job_id":null,"html_url":"https://github.com/soimort/hit-and-run","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soimort%2Fhit-and-run","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soimort%2Fhit-and-run/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soimort%2Fhit-and-run/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soimort%2Fhit-and-run/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soimort","download_url":"https://codeload.github.com/soimort/hit-and-run/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248271894,"owners_count":21075800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T12:26:17.424Z","updated_at":"2025-04-10T18:34:48.244Z","avatar_url":"https://github.com/soimort.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hit \u0026 run\n\nA simple command-line wrapper to compile, run and timekeep single-file programs more easily. Handy for competitive programming (ACM-ICPC, Google Code Jam, TopCoder, etc.)\n\n## Usage\n\n### #1\n\nCompile and run a program with timekeeping:\n\n```\n$ run SOURCE_FILE INPUT_FILE [ARGUMENTS] \u003e OUTPUT_FILE\n```\n\n(e.g. `run Foo.java test01.txt \u003e test01.out`)\n\nIf no input file is needed by the program, put \"`/`\" in place. (e.g. `run Foo.java / \u003e test01.out`)\n\n*Note: no compiler options can be passed if used this way.*\n\n### #2\n\nCompile:\n\n```\n$ hit SOURCE_FILE COMPILER_OPTIONS\n```\n\n(e.g. `hit Foo.java`)\n\nRun a compiled program with timekeeping:\n\n```\n$ run PROGRAM_FILE INPUT_FILE [ARGUMENTS] \u003e OUTPUT_FILE\n```\n\n(e.g. `run Foo test01.txt \u003e test01.out`)\n\nIf no input file is needed by the program, put \"`/`\" in place. (e.g. `run Foo / \u003e test01.out`)\n\n### Disable timekeeping\n\nThe `INPUT_FILE` parameter (or \"`/`\" if no input file needed), together with the rest of arguments, can be ignored. Doing so will **disable timekeeping** and use **standard input**. As usual, nothing can prevent you from redirecting input from a file, e.g. `run Foo \u003c test01.txt \u003e test01.out`\n\n### A few notes on timekeeping\n\nFirstly, timekeeping is **not guaranteed to be accurate** due to inevitable shell execution overhead. It serves only as a stopwatch so you know roughly how much time has elapsed while running your program.\n\nYou may run the following command to see the difference. The \"elapsed time\" shown in the stopwatch is always a little less than the real time elapsed. In most cases this small error doen't matter a lot, however you should be aware of the fact!\n\n```\n$ run \"sleep 10\" /\n  [running]\n  command: \tsleep 10\n\n  $ sleep 10\n  ================================ /dev/stdin\n  pid\t\t[8214]\n  elapsed\t0m9.7s\n  real\t\t0m10.001s\n  user\t\t0m0.000s\n  sys\t\t0m0.000s\n```\n\n## Demo\n\nMeasure the running time of computing the [Ackermann function](https://en.wikipedia.org/wiki/Ackermann_function) `A(3,12)` recursively in Java and C++:\n\n```\n$ cd samples\n$ ../run Ackermann.java / \u003e ackermann.out\n$ ../run ackermann.cpp / \u003e ackermann.out\n```\n\nCompile the C++ program with optimization first, then measure the running time:\n\n```\n$ ../hit ackermann.cpp -O3\n$ ../run ackermann / \u003e ackermann.out\n```\n\n## Language Support\n\n| Language        | Recognized extension          | Canonical compiler | Canonical runtime/interpreter |\n| --------------- | ----------------------------- | ------------------ | ----------------------------- |\n| **Java** | `.java` | `javac` | `java` |\n| **Groovy** | `.groovy` | `groovyc` | `groovy` |\n| **Scala** | `.scala` | `scalac` | `scala` |\n| **C#** | `.cs` | `mcs` | `mono` |\n| **Visual Basic .NET** | `.vb` | `vbnc` | `mono` |\n| **F#** | `.fs`, `.fsx` | `fsharpc` | `mono` |\n| **Fortran** | `.for`, `.f90`, `.f95`, `.f03`, `.f08` | `gfortran` | |\n| **BASIC** | `.bas` | `fbc` | |\n| **Pascal** | `.pas` | `fpc` | |\n| **Ada** | `.adb` | `gnatmake` | |\n| **C**  | `.c` | `gcc` | |\n| **C++** | `.cpp`, `.cc`, `.cxx`, `.c++` | `g++` | |\n| **Standard ML** | `.sml` | `mlton` | |\n| **OCaml** | `.ml` | `ocamlopt` | |\n| **Haskell** | `.hs` | `ghc` | |\n| **Idris** | `.idr` | `idris` | |\n\nAlternatively, you may assign environment variable `IMPL` to specify which implementation to use, e.g. `IMPL=clang++ hit ackermann.cpp`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoimort%2Fhit-and-run","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoimort%2Fhit-and-run","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoimort%2Fhit-and-run/lists"}