Giter Club home page Giter Club logo

prouter's Introduction

About

Prouter is a library that allows you to trace your code and visualize your algorithm.

Usages

Includes

#include "./includes/includes.h"

and you'd better do like this:

#include "./includes/includes.h"

int main() {

#include "./includes/predefine.h"
    
......

Trace a var

#include "./includes/predefine.h"

double a = 3.0;
a = 4.0;
a *= 2.0;

std::cout << textBuilder::varChangeHistoryText(&a) << std::endl;

Output:

3.000000 -> 4.000000 -> 8.000000

Trace a loop

#include "./includes/predefine.h"

auto tracer = prouter::traceLoop().named("loop 1");

int f[1000], i = 1, fc;
f[1] = 1;
f[2] = 1;

tracer.trace(&i.named("i"))
      .trace(&fc.named("fc"));

for (; i <= 10; ++i, tracer.loop()) {
    if (i >= 3)
        f[i] = f[i - 1] + f[i - 2];
    fc.setValue(f[i]);
}

tracer.end();

std::cout << std::endl << tracer.tableText() << std::endl;

Output:

╔═════════════════════════╗
║         loop 1          ║
╠═════════════════════════╣
║   ║ i        ║ fc       ║ 
║ 0 ║ 1 -> 2   ║ 0 -> 1   ║ 
║ 1 ║ 2 -> 3   ║ 1 -> 1   ║ 
║ 2 ║ 3 -> 4   ║ 1 -> 2   ║ 
║ 3 ║ 4 -> 5   ║ 2 -> 3   ║ 
║ 4 ║ 5 -> 6   ║ 3 -> 5   ║ 
║ 5 ║ 6 -> 7   ║ 5 -> 8   ║ 
║ 6 ║ 7 -> 8   ║ 8 -> 13  ║ 
║ 7 ║ 8 -> 9   ║ 13 -> 21 ║ 
║ 8 ║ 9 -> 10  ║ 21 -> 34 ║ 
║ 9 ║ 10 -> 11 ║ 34 -> 55 ║ 
╚═════════════════════════╝

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.