|
| 1 | +# Multiple Binary Input Example |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The goal of this example project is to test the performance of Engflow's remote execution and caching service based on the number of input binary files in the dependency graph. The project contains a `genrule` that generates a specified number of Java binaries for the `genbinary` Java library, which are then listed as dependencies in the main binary. The `Main.java` file loops through each generated class and calls its `greetNum` method. |
| 6 | + |
| 7 | +## Project Structure |
| 8 | + |
| 9 | +- `java/com/engflow/internship/binaryinput/Main.java`: Main class that dynamically loads and invokes methods from generated classes. |
| 10 | +- `java/com/engflow/internship/binaryinput/BUILD`: Bazel build file for the `main` java binary and the `genbinary` library. |
| 11 | + |
| 12 | +## Usage |
| 13 | + |
| 14 | +To generate the test files, build the `genbinary` library using the `genrule`: |
| 15 | +```sh |
| 16 | +bazel build //java/com/engflow/internship/binaryinput:genbinary |
| 17 | +``` |
| 18 | + |
| 19 | +Then, the program can be run with the following command: |
| 20 | +```sh |
| 21 | +bazel run //java/com/engflow/internship/binaryinput:main |
| 22 | +``` |
| 23 | + |
| 24 | +## How It Works |
| 25 | + |
| 26 | +1. **Generation of Java Binaries:** |
| 27 | + - The `genrule` in the `BUILD` file generates a specified number of Java classes (`Hello1.java`, `Hello2.java`, ..., `HelloN.java`). |
| 28 | + - Each generated class contains a `greetNum` method that prints a unique message. |
| 29 | + |
| 30 | +2. **Main Class Execution:** |
| 31 | + - The `Main.java` file in `binaryinput` dynamically loads each generated class using reflection. |
| 32 | + - It then invokes the `greetNum` method of each class, printing the corresponding message. |
| 33 | + |
| 34 | +## Configuration |
| 35 | + |
| 36 | +The number of generated files is controlled by the `NUM_FILES` variable in the `BUILD` file of the `binaryinput` package. Modify this variable to change the number of generated classes and observe the performance impact on Engflow's remote execution and caching service. |
| 37 | + |
| 38 | +## Example |
| 39 | + |
| 40 | +To generate and run the program with 10 input binary files: |
| 41 | + |
| 42 | +1. Set `NUM_FILES` to 10 in `java/com/engflow/internship/binaryinput/BUILD`. |
| 43 | +2. Build the `genbinary` library: |
| 44 | + ```sh |
| 45 | + bazel build //java/com/engflow/internship/binaryinput:genbinary |
| 46 | + ``` |
| 47 | +3. Run the `main` binary: |
| 48 | + ```sh |
| 49 | + bazel run //java/com/engflow/internship/binaryinput:main |
| 50 | + ``` |
| 51 | + |
| 52 | +This will generate 10 Java classes, build the `genbinary` library, and run the `main` binary, which will print messages from each generated class. |
0 commit comments