Coder Social home page Coder Social logo

shellscripting's Introduction

Debugging and Execution Time Measurement Toolkit

This repository contains two scripts, Dprintf.sh and measure.sh, designed to aid in debugging and measuring the execution time of C code respectively.

Dprintf.sh

Dprintf.sh is a bash script intended for debugging C code by automatically adding printf() statements before every curly bracket { to help identify where the code gets stuck during execution.

Usage

  1. Place Dprintf.sh in the directory containing your C source file.
  2. Open a terminal and navigate to the directory containing both Dprintf.sh and your C source file.
  3. Run the script using the command:
    ./Dprintf.sh your_source_file.c
    
  4. This will generate a new file named debug_your_source_file.c with printf() statements inserted before each { in your code.

measure.sh

measure.sh is a bash script used to measure the execution time of C code. It runs the code multiple times and calculates the average execution time.

Usage

  1. Place measure.sh in the directory containing your C source file.
  2. Open a terminal and navigate to the directory containing both measure.sh and your C source file.
  3. Run the script using the command:
    ./measure.sh your_source_file.c
    
  4. This will compile your_source_file.c and execute it multiple times, measuring the execution time each time.
  5. Finally, it will display the average execution time of your code.

Note

  • These scripts are intended to be used with C source files.
  • Make sure you have appropriate permissions to execute the scripts (chmod +x Dprintf.sh measure.sh).
  • Always review the modified/debugged code before running it in a production environment.
  • For accurate measurement results, it's recommended to compile the C code with optimizations disabled (-O0 for GCC).
  • These scripts can help in debugging and performance tuning, but they should not be solely relied upon for critical applications. Always use proper debugging and profiling tools for comprehensive analysis.

shellscripting's People

Contributors

aaref5720 avatar

Stargazers

Mohamed Magdi avatar

Watchers

 avatar

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.