Skip to content

Commit

Permalink
Merge branch 'master' into fix/paints
Browse files Browse the repository at this point in the history
  • Loading branch information
Sciguymjm committed Nov 10, 2020
2 parents 5bc6b41 + f9e4854 commit 42b29b3
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,16 @@ _json = carball.decompile_replay('9EB5E5814D73F55B51A1BD9664D4CBF3.replay',
Analyze a JSON game object:
```Python
import carball
import os
import gzip
from carball.json_parser.game import Game
from carball.analysis.analysis_manager import AnalysisManager

# _json is a JSON game object (from decompile_replay)
game = Game()
game.initialize(loaded_json=_json)

analysis_manager = AnalysisManager(game)
analysis_manager.create_analysis()

# write proto out to a file
# read api/*.proto for info on the object properties
with open(os.path.join('output.pts'), 'wb') as fo:
analysis_manager.write_proto_out_to_file(fo)

# write pandas dataframe out as a gzipped numpy array
with gzip.open(os.path.join('output.gzip'), 'wb') as fo:
analysis_manager.write_pandas_out_to_file(fo)

# return the proto object in python
proto_object = analysis_manager.get_protobuf_data()
Expand All @@ -107,6 +98,35 @@ json_oject = analysis_manager.get_json_data()
dataframe = analysis_manager.get_data_frame()
```

You may want to save carball analysis results for later use:

```python
# write proto out to a file
# read api/*.proto for info on the object properties
with open('output.pts', 'wb') as fo:
analysis_manager.write_proto_out_to_file(fo)

# write pandas dataframe out as a gzipped numpy array
with gzip.open('output.gzip', 'wb') as fo:
analysis_manager.write_pandas_out_to_file(fo)
```

Read the saved analysis files:

```python
import gzip
from carball.analysis.utils.pandas_manager import PandasManager
from carball.analysis.utils.proto_manager import ProtobufManager

# read proto from file
with open('output.pts', 'rb') as f:
proto_object = ProtobufManager.read_proto_out_from_file(f)

# read pandas dataframe from gzipped numpy array file
with gzip.open('output.gzip', 'rb') as f:
dataframe = PandasManager.read_numpy_from_memory(f)
```

### Command Line

Carball comes with a command line tool to analyze replays. To use carball from the command line:
Expand Down

1 comment on commit 42b29b3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Carball Benchmarks short_sample

Benchmark suite Current: 42b29b3 Previous: f9e4854 Ratio
carball/tests/benchmarking/benchmarking.py::test_short_sample 0.8128947071251461 iter/sec (stddev: 0.02103820534402889) 1.0632090723555239 iter/sec (stddev: 0.016734510376562064) 1.31

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.