fredia commented on code in PR #66: URL: https://github.com/apache/flink-benchmarks/pull/66#discussion_r1126260185
########## regression_report_v2.py: ########## @@ -0,0 +1,108 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ +import argparse +import json +import urllib +import urllib2 + +from regression_report import loadBenchmarkNames + +""" +This is a regression detection algorithm based on the historical maximum/minimum value, please refer +to https://docs.google.com/document/d/1Bvzvq79Ll5yxd1UtC0YzczgFbZPAgPcN3cI0MjVkIag/edit the detailed design. +""" + +DEFAULT_CODESPEED_URL = 'http://codespeed.dak8s.net:8000/' +ENVIRONMENT = 2 +DEFAULT_THRESHOLD = 0.04 +DEFAULT_BASELINE = 30 + +""" +Returns a list of benchmark results +""" +def loadHistoryData(codespeedUrl, exe, benchmark, downloadSamples): + url = codespeedUrl + 'timeline/json/?' + urllib.urlencode({'exe': exe, 'ben': benchmark, 'env': ENVIRONMENT, 'revs': downloadSamples}) + f = urllib2.urlopen(url) + response = f.read() + f.close() + timelines = json.loads(response)['timelines'][0] + result = timelines['branches']['master'][exe] + lessIsbBetter = (timelines['lessisbetter'] == " (less is better)") + return result, lessIsbBetter + +def checkWithMax(urlToBenchmark, stds, scores, index, baselineSize): + sustainable_x = [min(scores[i - 2 : i + 1]) for i in range(index - baselineSize, index)] + baseline_throughput = max(sustainable_x) + current_throughput = max(scores[index - 3 : index]) + current_unstable = stds[index] / current_throughput + if 1 - current_throughput / baseline_throughput > max(DEFAULT_THRESHOLD, 2 * current_unstable): + print "<%s|%s> baseline=%s current_value=%s" % (urlToBenchmark, benchmark, baseline_throughput, current_throughput) + +def checkWithMin(urlToBenchmark, stds, scores, index, baselineSize): + sustainable_x = [max(scores[i - 2 : i + 1]) for i in range(index - baselineSize, index)] + baseline_throughput = min(sustainable_x) + current_throughput = min(scores[index - 3 : index]) + current_unstable = stds[index] / current_throughput + if 1 - current_throughput / baseline_throughput < -1.0 * max(DEFAULT_THRESHOLD, 2 * current_unstable): + print "<%s|%s> baseline=%s current_value=%s" % (urlToBenchmark, benchmark, baseline_throughput, current_throughput) + +def checkBenchmark(args, exe, benchmark): + results, lessIsbBetter = loadHistoryData(args.codespeed, exe, benchmark, args.downloadSamples) + results = list(reversed(results)) + scores = [score for (date, score, deviation, commit, branch) in results] + stds = [deviation for (date, score, deviation, commit, branch) in results] + + urlToBenchmark = args.codespeed + 'timeline/#/?' + urllib.urlencode({ + 'ben': benchmark, + 'exe': exe, + 'env': ENVIRONMENT, + 'revs': args.downloadSamples, + 'equid': 'off', + 'quarts': 'on', + 'extr': 'on'}) + + if len(results) < args.baseLine: + return + + if lessIsbBetter: + checkWithMin(urlToBenchmark, stds, scores, len(scores) - 1, args.baseLine) + else: + checkWithMax(urlToBenchmark, stds, scores, len(scores) - 1, args.baseLine) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Regression report based on Max/Min value') + parser.add_argument('--base-line-size', dest='baseLine', required=False, default=DEFAULT_BASELINE, type=int, Review Comment: `downloadSamples` is copied from `report_gression.py`, I guess it is mainly used to specify the returned URL in regression report. Suppose we make it equal to baselineSize, set them to 30, the codespeed can only show 10 sample points instead of 30. ![image](https://user-images.githubusercontent.com/18653940/223094237-a12a9dbf-c6f9-41c5-a4bf-ea6bddd21c4c.png) So I rename it to `displaySamples`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org