Giter Club home page Giter Club logo

code-analyzer's Introduction

Code-Analyzer Python Code Benchmarking Framework

New Features!

  • Test Your Code execution performance , memory required and cprofile analysis
  • Automatically downloads from github
  • Visualize the data into more understandable form
  • Added support for Ruby

Analyzing python, ruby code for performance evaluation. Libraries used in this project are timeit , cProfile and tracemalloc. timeit is used for analyzing the time complexity which executes the given code for 5 iteration and returns the time taken to execute. cProfile is used to analyze the function calls and time required to execute each function calls tracemalloc is used to analyze the peak memory used by the targeted function.


Installation Guide

  1. make new virtual environment with python 3.7
  2. install requests and pandas
  3. install matplotlib

Uses

  1. Create an object of Benchmark Class with url, expected_output , function params ,code_type by default code type is set to python only

demo = Benchmark(github_repo_url,expected_output,params,code_type='python'')

  1. Start the benchmarking process demo.start(params='all', save=False, visualize=True)

Note: Complete means the tested function returns something and correctness means it matches the expected output

Example Python

Testing this code in Code Analyzer

class Testing:
    def setup(params):
        # return [i for i in range(params)]
        l =[]
        for i in range(params):
            for j in range(params):
                for k in range(params):
                    l.append(i*j*k)
        return l

Code for Demo.py For Python Code

from AllBenchmark.Benchmark import Benchmark

expected_output = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3,
                   4, 0, 2, 4, 6, 8, 0, 3, 6, 9, 12, 0, 4, 8, 12, 16, 0, 0, 0, 0, 0, 0, 2, 4, 6, 8, 0, 4, 8, 12, 16, 0,
                   6, 12, 18, 24, 0, 8, 16, 24, 32, 0, 0, 0, 0, 0, 0, 3, 6, 9, 12, 0, 6, 12, 18, 24, 0, 9, 18, 27, 36,
                   0, 12, 24, 36, 48, 0, 0, 0, 0, 0, 0, 4, 8, 12, 16, 0, 8, 16, 24, 32, 0, 12, 24, 36, 48, 0, 16, 32,
                   48, 64]

url = "https://github.com/diparyal/python_test.git"

params = 5

demo = Benchmark(url=url, expected_output=expected_output, params=params, code_type='python')

score = demo.start(visualize=True, save=True, params='all')

print(score)

Output:

Demo Output

Cprofile

Time


Example Ruby

Testing this code in Code Analyzer

module Testing
  def Testing.setup(params)
    return "hello World" + params;  
  end
end

Code for Demo.py For Python Code

from AllBenchmark.Benchmark import Benchmark

expected_output = "hello World5"

url = "https://github.com/dcostersabin/ruby.git"

params = '5'

demo = Benchmark(url=url, expected_output=expected_output, params=params, code_type='ruby')

score = demo.start(visualize=True, save=True, params='all')

print(score)

Output:

Demo Output

Cprofile

Time

code-analyzer's People

Contributors

dcostersabin avatar

Stargazers

 avatar

Watchers

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