-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
14,323 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"tags": [ | ||
"parameters" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"sort_by = 'edit'\n", | ||
"top_n = 10" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from code_data_science import data_table as dt\n", | ||
"\n", | ||
"df = dt.read_csv(\"../samples/recipe_performance.csv\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import plotly.express as px\n", | ||
"\n", | ||
"# Group by recipe and sum up the times\n", | ||
"grouped = df.groupby('recipe').agg({\n", | ||
" 'scanTotalTime': 'sum',\n", | ||
" 'editTotalTime': 'sum'\n", | ||
"}).reset_index()\n", | ||
"\n", | ||
"byTotalTime = f'{sort_by}TotalTime'\n", | ||
"\n", | ||
"# Sort by the top N\n", | ||
"grouped = grouped.sort_values(by=byTotalTime, ascending=False).head(top_n)\n", | ||
"\n", | ||
"# Sort again to have the longest at the top\n", | ||
"grouped = grouped.sort_values(by=byTotalTime, ascending=True)\n", | ||
"\n", | ||
"# adjust topN if it exceeds the unique recipes\n", | ||
"top_n = min(top_n, len(grouped))\n", | ||
"top_n\n", | ||
"\n", | ||
"# Calculate the height of the plot\n", | ||
"height_per_recipe = 25\n", | ||
"total_height = top_n * height_per_recipe + 150\n", | ||
"\n", | ||
"\n", | ||
"fig = px.bar(grouped,\n", | ||
" x=byTotalTime,\n", | ||
" y='recipe',\n", | ||
" title=f'Total {sort_by} time for top {top_n} recipes',\n", | ||
" labels={byTotalTime: f'Total {sort_by} time', 'recipe': 'Recipe'},\n", | ||
" color=byTotalTime,\n", | ||
" color_continuous_scale='Bluered',\n", | ||
" orientation='h',\n", | ||
" height=total_height\n", | ||
" )\n", | ||
"\n", | ||
"fig.show()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
type: specs.moderne.io/v1beta/visualization | ||
name: io.moderne.RecipePerformance | ||
displayName: Recipe performance | ||
description: Display the top N recipes by edit time or scan time. | ||
recipe: org.openrewrite.* | ||
dataTable: org.openrewrite.table.RecipeRunStats | ||
options: | ||
- sort_by: | ||
displayName: Sort the recipes by | ||
description: > | ||
Sort the recipes by time spent scanning or time spent editing. (default: scan) | ||
valid: | ||
- scan | ||
- edit | ||
required: false | ||
- top_n: | ||
displayName: Top N recipes | ||
description: > | ||
The number of recipes to plot. (default: 10) | ||
required: false |
Oops, something went wrong.