lindong28 commented on code in PR #66:
URL: https://github.com/apache/flink-benchmarks/pull/66#discussion_r1125658942


##########
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):

Review Comment:
   Should we use `args.trendThreshold` instead of reading the hardcoded 
threshold value?
   
   Also, could you help replace `2 * current_unstable` with 
`args.minUnstabilityMultiplier * current_unstability`? 



##########
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,
+                        help='Number of samples taken as the base line.')
+    parser.add_argument('--download-samples-size', dest='downloadSamples', 
required=False, default=200,
+                        type=int,
+                        help='Number of samples download from the codespeed. 
Not all values are '
+                             'working.')
+    parser.add_argument('--trend-threshold', dest='trendThreshold', 
required=False,
+                        default=DEFAULT_THRESHOLD, type=float,
+                        help="Tolerated threshold for change between baseline 
and recent trend value "

Review Comment:
   It is not very clear what `trend value` and `Tolerated` mean.
   
   How about using the following doc:
   
   ```
   parser.add_argument('--min-regression-ratio', dest='minRegressionRatio', 
required=False,
                       default=0.04, type=float,
                       help='A regression should be alerted only if the ratio 
of change between the baseline '
                            'throughput and the current throughput exceeds the 
configured value.')
   ```
   



##########
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,
+                        help='Number of samples taken as the base line.')
+    parser.add_argument('--download-samples-size', dest='downloadSamples', 
required=False, default=200,
+                        type=int,
+                        help='Number of samples download from the codespeed. 
Not all values are '
+                             'working.')
+    parser.add_argument('--trend-threshold', dest='trendThreshold', 
required=False,
+                        default=DEFAULT_THRESHOLD, type=float,
+                        help="Tolerated threshold for change between baseline 
and recent trend value "
+                             "in percentages")
+    parser.add_argument('--codespeed', dest='codespeed', 
default=DEFAULT_CODESPEED_URL,

Review Comment:
   Would the following be more readable?
   
   ```
   parser.add_argument('--codespeed-url', dest='codespeedUrl', 
default="http://codespeed.dak8s.net:8000/";,
                       help='The codespeed url.')
   ```
   



##########
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)

Review Comment:
   It seems that `checkWithMax` and `checkWithMin` shares a lot of logic with 
each other.
   
   Would it be simpler to do something like this:
   
   ```
   if lessIsbBetter:
       scores = [-1 * score for score in scores]
   detectRegression(urlToBenchmark, stds, scores, len(scores) - 1,  
args.baseLine)
   ```



##########
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,
+                        help='Number of samples taken as the base line.')
+    parser.add_argument('--download-samples-size', dest='downloadSamples', 
required=False, default=200,

Review Comment:
   Instead of letting users specify the number of commit points, would it be 
more useful to let users specify the number of days and let benchmark script 
fetch commit points from these days?
   
   If we use a given number of commit points, then the baseline will be changed 
if there are a lot of commit points in a day.



##########
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:
   Not sure if I understand the difference between this argument and 
`downloadSamples`. Can users configure just one of them?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to