The data-structure-inferrer package

[Tags: mit, program]

This project is meant to be a compiler feature/wrapper that analyzes your code and chooses the best data structure depending on your source code. It analyzes the functions used on a wildcard data structure and chooses the type of structure that minimizes the time complexity. It will support C language and hopefully some other languages too.


[Skip to ReadMe]

Properties

Version1.0
Change logNone available
Dependenciesansi-terminal (>=0.5.0 && <2), array (>=0.3.0.3 && <1), base (>=4.3.0 && <5), deepseq (>=1.2.0.1 && <2), derive (>=2.5.4 && <3), directory (>=1.1.0.1 && <2), filepath (>=1.2.0.1 && <2), language-c (>=0.4.2 && <1), mtl (>=2.0.1.0 && <3), random (>=1.0.1.1 && <2), safe (>=0.3.3 && <1), utility-ht (>=0.0.7.1 && <1) [details]
LicenseMIT
AuthorAleksander Balicki
MaintainerAleksander Balicki <balicki.aleksander@gmail.com>
CategoryDevelopment
Home pagehttp://github.com/alistra/data-structure-inferrer
Source repositoryhead: git clone http://github.com/alistra/data-structure-inferrer
Executablesdsinf
UploadedTue Dec 27 12:34:12 UTC 2011 by AleksanderBalicki
DistributionsNixOS:1.0
Downloads246 total (8 in last 30 days)
Votes
0 []
StatusDocs not available [build log]
Last success reported on 2015-05-18 [all 2 reports]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for data-structure-inferrer-1.0

About the project

This project is meant to be a compiler feature/wrapper that analyzes your code and chooses the best data structure depending on your source code. It analyzes the functions used on a wildcard data structure and chooses the type of structure that minimizes the time complexity. It will support C language and hopefully some other languages too.

Usage

alistra@bialobrewy data-structure-inferrer % ./dsinf -h
dsinf
  -o file    --output=file    Output file
  -r         --recommend      Give recommendations about the data structure in the supplied code (default)
  -a         --advice         Give advice about the data structure in the supplied code
  -c         --compile        Compile the code with recommended structure linked
  -i         --inline         Inline the code implementing the recommended structure in the supplied code
  -v         --verbose        Enable verbose messages
  -h         --help           Show help

Example (not yet working)

For the following C file:

//example.c
typedef int dstype;
#include <ds.h>
int main()
{
    ds d1;
    dselem e;

    for(int i = 0; i < 20; i++)
    {
        insert_d(d1, i);
        printf("%d\n", search_d(d1, i));
        update_d(d1, i, 2*i);
    }

    printf("%d\n", max_d(d1));
}

you'll invoke:

dsinf -c example.c

and it will automatically compile the file and link the matching library with data structure implementation (here red-black trees with max element cache).

For now

For now it works as a standalone code analyzer for a toy language that prints the most appropriate structure.

Examples

You can run tests by running runIlTests from the Tests.hs file. These tests (Il/tests subdirectory) are source code in a simple imperative language. The analyzer infers the best data structure for operations used in the test program.

*Tests> runIlTests
Test File Il/tests/1.il
The recommended structure for ds is:
Hashtable
Test File Il/tests/2.il
The recommended structure for ds is:
Red-Black Trees with extreme element caching
The recommended structure for ds2 is:
Red-Black Trees with extreme element caching
Test File Il/tests/3.il
The recommended structure for ds is:
Red-Black Trees with extreme element caching
The recommended structure for ds2 is:
Linked List with extreme element caching

Low Level

For now you can get the best structures depending on operations used in your program (if you manually put it in the invocation):

*AllStructures> recommendAllDs [InsertVal, ExtremalVal]
[Fibonacci Heap,Binomial Heap]
*AllStructures> recommendAllDs [InsertVal, FindByVal ]
[Hashtable]
*AllStructures> recommendAllDs [InsertVal, FindByVal, ExtremalVal]
[Red-Black Trees]

There's an advice mode which is formatted more nicely:

*Advice> printAdvice [InsertVal, UpdateByVal, DeleteExtremalVal ]
Currently, the recommended data structure is: Red-Black Trees
You could use Hashtable, if you removed the following operations:
* DeleteExtremalVal