GithubHelp home page GithubHelp logo

rapotekhin / filter_implementation_comparison Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 6 KB

This project evaluates the performance and correctness of filter functions implemented in C, C++, and Python

C 6.21% C++ 7.23% Python 86.56%

filter_implementation_comparison's Introduction

Filter Implementation Comparison

This project evaluates the performance and correctness of filter functions like array[indx] implemented in C, C++, and Python, interfacing C and C++ through Python using the ctypes library. The goal is to compare how each implementation handles filtering operations, both in terms of speed and output accuracy.

Prerequisites

  • GCC: For compiling C and C++ code.
  • Python: Version 3.6 or newer.
  • NumPy: Required for array operations in Python.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Compiling the Code

  1. C Implementation

    Navigate to the project directory and compile the C code using:

    gcc -O3 -Wall -shared -std=c11 -fPIC filter.c -o libfilter_c.so
  2. C++ Implementation

    Compile the C++ code using:

    g++ -O3 -Wall -shared -std=c++11 -fPIC filter.cpp -o libfilter_cpp.so

Installation

Install the necessary Python packages using pip:

pip install numpy

Running the Tests

Execute the script to compare performance and verify the correctness of the outputs:

python main.py

Files

  • filter.c: Contains the C implementation of the filter function.
  • filter.cpp: Contains the C++ implementation of the filter function.
  • main.py: Python script to test and compare the C and C++ implementations.
  • README.md: Documentation for setting up and running the project.

Expected Outputs

Upon running the Python script, you will see:

  • Timing results for each implementation (C, C++, and Python).
  • Validation results checking if all implementations produce identical results.

Sample Output

C++ version: Mean = 3.372 ms, Std Dev = 0.125248 ms
C version: Mean = 3.125 ms, Std Dev = 0.045240 ms
Python version: Mean = 4.437 ms, Std Dev = 0.042556 ms
----------------------------------------
Comparison between C++ and C outputs: identical
Comparison between C++ and Python outputs: identical
Comparison between C and Python outputs: identical
All implementations produce identical results.

Contributing

Contributions to improve the project are welcome. Feel free to fork this repository and propose changes through pull requests.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

filter_implementation_comparison's People

Contributors

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