Giter Site home page Giter Site logo

profiling-with-shared-lib-example's Introduction

C++ Shared Libraries with Callback and Profiling Example

Overview

This project demonstrates how to create and use two shared libraries in C++:

  1. libprint - A library that provides a function to print a string and an API to register callbacks that are triggered on function entry and exit.
  2. libprofiler - A library that registers callbacks to record timestamps and profile the execution time of the function provided by libprint.

The project also includes an application that uses these libraries to print a string and profile the function execution time.

Build Instructions

  1. Ensure you have a C++ compiler (e.g., g++) installed on your system.
  2. Open a terminal and navigate to the directory containing the project files.
  3. Run the following command to build the shared libraries and the application:
make

Run Instructions

To build and run the application with the code instrumented to start the profiling:

make run-instrumented

You should see the printed string and the profiling output indicating the function's execution time.

To build and run the application with the code not instrumented:

make run-not-instrumented

To build and run the application with the code not instrumented but externally starting the profiling using LD_PRELOAD=./libprofiler.so and ENABLE_PROFILING=1:

make run-ld-preload

Explanation

libprint Library

  • printString(const char* str): Prints the given string.
  • registerEnterCallback(Callback callback): Registers a callback function to be called on function entry.
  • registerExitCallback(Callback callback): Registers a callback function to be called on function exit.

libprofiler Library

  • registerProfilingCallbacks(): Registers the enter and exit callbacks to record timestamps and profile the execution time of the printString function.

License

This project is licensed under the MIT License.

profiling-with-shared-lib-example's People

Contributors

marceloamaral 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.