Created
June 10, 2021 13:18
-
-
Save ntrrgc/73b7d05768ab6c23aab0d6058fbbd251 to your computer and use it in GitHub Desktop.
Plots the number of WPT tests passing for a given feature and a set of browsers over time
This file contains hidden or 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
#!/usr/bin/python3 | |
# Instructions: | |
# 1. Checkout: https://github.com/Ecosystem-Infra/wpt-results-analysis.git | |
# 2. cd compat-2021 | |
# 3. Edit main.js like this: | |
# const CATEGORIES = [ | |
# + 'media-source', | |
# + 'media', | |
# ]; | |
# ... | |
# - const products = ['chrome', 'firefox', 'safari']; | |
# + const products = ['chrome', 'firefox', 'safari', 'webkitgtk']; | |
# 4. Add {category-name}-tests.txt file(s) with the WPT tests of the new categories (test paths must start with /) | |
# 5. Run `node main.js` and/or `node main.js --experimental` (depending on the desired browser branch type). | |
# 6. Run this script in the same folder. | |
import matplotlib.pyplot as plt | |
import matplotlib.ticker as mtick | |
import numpy as np | |
import pandas | |
px = 1 / plt.rcParams['figure.dpi'] # pixel in inches | |
def make_plot(feature, browser_type): | |
fig, ax = plt.subplots(figsize=(800*px, 600*px), constrained_layout=True) | |
a = pandas.read_csv(f"unified-scores-{browser_type}.csv") | |
browsers = ["chrome", "firefox", "safari", "webkitgtk"] | |
colors = ["blue", "red", "orange", "green"] | |
ax.set_title(f"WPT tests passing: {feature} (branch: {browser_type})") | |
ax.set_ylim([0, 1]) | |
plt.xticks(rotation=40) | |
ax.yaxis.set_ticks(list(np.linspace(0, 1, 11))) | |
ax.yaxis.set_major_formatter(mtick.PercentFormatter(xmax=1)) | |
for browser, color in zip(browsers, colors): | |
ax.plot(pandas.to_datetime(a["date"], format="%Y-%m-%d"), | |
a[f"{browser}-{feature}"], | |
label=browser, color=color) | |
ax.legend() | |
plt.grid() | |
return plt | |
def generate_all(): | |
for browser_type in ["stable", "experimental"]: | |
for feature in ["media", "media-source"]: | |
make_plot(feature, browser_type) | |
plt.savefig(f"support-feature-{feature}-{browser_type}.png") | |
if __name__ == "__main__": | |
make_plot("media-source", "experimental").show() | |
generate_all() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment