Giter Site home page Giter Site logo

thii / uber-poet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uber/uber-poet

0.0 1.0 0.0 1.01 MB

A mock swift project generator & build runner to help benchmark various module dependency graphs.

License: Apache License 2.0

Python 93.39% Shell 0.98% Starlark 3.87% Ruby 1.77%

uber-poet's Introduction

Uber Poet

CII Best Practices Build Status

This python app makes mock Xcode Swift / ObjC app projects with Buck, Bazel and CocoaPods. It lets us test different Swift / ObjC module configurations to see how much build speed is affected by different dependency graphs with identical amounts of code. There are two main command line apps:

  • genproj.py which generates one app which you have to build manually yourself. Either with buck, bazel or xcodebuild.
  • multisuite.py, which generates all module configs, builds them, records how long they take to build into a CSV and outputs it's results to a directory passed in the command line. Essentially a benchmark test suite. Can take several hours to run depending how many lines of code each app takes.

This app was architected so other languages, graph generators or build systems wouldn't be much work to add. Theoretically you could extend this app to generate java gradle android apps with the same dependency graph types.

How to Install / Dependencies

With a mac computer that can run macOS 10.13+, install all the dependencies below:

Depending on which project generator you plan to use, you will need to install at least one of the following:

Then:

  • Download / git clone this project into a folder.
  • Run pipenv install to install the required python dependencies.
  • If you want to run unit tests or develop for this app, make sure to run pipenv install --dev

How to Use

After installing all required dependencies:

See pipenv run ./genproj.py -h or pipenv run ./mulisuite.py -h for general help. Also take a look at the shell scripts in examples/ to see examples on how to use these command line programs.

Here a few quick examples:

Generate a project using Buck:

pipenv run ./genproj.py --output_directory "$HOME/Desktop/mockapp" \
                        --project_generator_type "buck" \
                        --blaze_module_path "/mockapp" \
                        --gen_type flat \
                        --swift_lines_of_code 150000

Generate a project using Bazel:

pipenv run ./genproj.py --output_directory "$HOME/Desktop/mockapp" \
                        --project_generator_type "bazel" \
                        --blaze_module_path "/mockapp" \
                        --gen_type flat \
                        --swift_lines_of_code 150000

Generate a project using CocoaPods:

pipenv run ./genproj.py --output_directory "$HOME/Desktop/mockapp" \
                        --project_generator_type "cocoapods" \
                        --gen_type flat \
                        --swift_lines_of_code 150000

You may also generate a project that includes both Swift and ObjC:

pipenv run ./genproj.py --output_directory "$HOME/Desktop/mockapp" \
                        --project_generator_type "cocoapods" \
                        --gen_type flat \
                        --swift_lines_of_code 100000 \
                        --objc_lines_of_code 50000
# You usually want to use `caffeinate` to prevent your computer 
# from going to sleep during a multi hour build test suite.             
caffeinate -s pipenv run \
./multisuite.py --log_dir "$HOME/Desktop/multisuite_build_results" \
                --app_gen_output_dir "$HOME/Desktop/multisuite_build_results/app_gen"

You may also generate a project that matches your own project's dependency graph by using --gen_type dot parameter as well as supplying the location of the dot file that represents the graph:

pipenv run ./genproj.py --output_directory "$HOME/Desktop/mockapp" \
                        --project_generator_type "cocoapods" \
                        --gen_type dot \
                        --dot_file_path "$HOME/MyProject/my_project_graph.dot" \
                        --dot_root_node_name "MyProject" \
                        --swift_lines_of_code 150000

Examples on how to generate a dot file:

Using Buck:

buck query \"deps(target)\" --dot > file.gv

Using Bazel:

bazel query "deps(target)" --output graph > graph.in

Using CocoaPods:

Install and use the cocoapods-dependencies plugin.

You may also supply an optional JSON file to be used as a LOC map. This allows you to generate a project from your own dependency graph in which each generated module has proportional LOC to your original graph.

pipenv run ./genproj.py --output_directory "$HOME/Desktop/mockapp" \
                        --project_generator_type "cocoapods" \
                        --gen_type dot \
                        --dot_file_path "$HOME/MyProject/my_project_graph.dot" \
                        --dot_root_node_name "MyProject" \
                        --loc_json_file_path "$HOME/MyProject/cloc_mappings.json"

Please note the format of the JSON file for LOC mappings must look like:

{
    "MyLibrary":500,
    "MyOtherLibrary":42
}

You may also specify a LOC mapping file that includes the language that you want to use for each module, for example:

{
    "MyLibrary": { "loc": 500, "language": "Objective-C" },
    "MyOtherLibrary":42
}

NOTE: All nodes found in your dot file must be present in your JSON LOC mappings file.

Examples on how to get the CLOC:

cloc file.swift --include-lang="Swift" --json

Parse the JSON with your favorite language and read the "code" value from the "SUM" key.

How to Contribute / Develop

Take a look at docs/CONTRIBUTING.md!

Project Status

This project is stable and being incubated for long-term support.

Licence

This project is covered by the Apache License, Version 2.0:

http://www.apache.org/licenses/LICENSE-2.0

LICENSE.txt

uber-poet's People

Contributors

dnkoutso avatar uber-mahyar avatar uber-mahyar2 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.