فهرست منبع

Merge pull request #100 from vmarkovtsev/master

Fix days comparison
Vadim Markovtsev 6 سال پیش
والد
کامیت
143d495726
10فایلهای تغییر یافته به همراه249 افزوده شده و 144 حذف شده
  1. 3 0
      .flake8
  2. 2 1
      .travis.yml
  3. 2 1
      contrib/_plugin_example/plot_churn.py
  4. 5 9
      internal/burndown/file.go
  5. 23 12
      internal/core/pipeline.go
  6. 12 3
      internal/core/pipeline_test.go
  7. 79 67
      internal/pb/pb.pb.go
  8. 2 0
      internal/pb/pb.proto
  9. 99 43
      internal/pb/pb_pb2.py
  10. 22 8
      labours.py

+ 3 - 0
.flake8

@@ -0,0 +1,3 @@
+[flake8]
+max-line-length=99
+exclude=.git,internal/pb/pb_pb2.py

+ 2 - 1
.travis.yml

@@ -54,7 +54,7 @@ before_install:
   - export PATH=~/usr/bin:$PATH
   - make --version
   - pip3 --version
-  - pip3 install --user --no-build-isolation -r requirements.txt tensorflow
+  - pip3 install --user --no-build-isolation -r requirements.txt tensorflow flake8
   - docker run -d --privileged -p 9432:9432 --name bblfshd bblfsh/bblfshd
   - docker exec -it bblfshd bblfshctl driver install python bblfsh/python-driver:latest
   - docker exec -it bblfshd bblfshctl driver install go bblfsh/go-driver:latest
@@ -68,6 +68,7 @@ script:
   - set -e
   - go vet -tags tensorflow ./...
   - golint -set_exit_status ./...
+  - flake8
   - if [[ $TRAVIS_GO_VERSION != 1.9.* ]]; then go test -coverpkg=all -v -cpu=1,2 -coverprofile=coverage.txt -covermode=count gopkg.in/src-d/hercules.v4/... && sed -i '/cmd\/hercules\|core.go/d' coverage.txt; fi
   - if [[ $TRAVIS_GO_VERSION = 1.9.* ]]; then go test -v -cpu=1,2 gopkg.in/src-d/hercules.v4/...; fi
   - $GOPATH/bin/hercules version

+ 2 - 1
contrib/_plugin_example/plot_churn.py

@@ -59,7 +59,8 @@ def plot_churn(name, data, url, beginTime, endTime, output, fmt, tick_interval):
         spine.set_visible(False)
     pyplot.gca().xaxis.set_major_locator(mdates.DayLocator(interval=tick_interval))
     pyplot.gca().xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m-%d"))
-    pyplot.tick_params(top="off", bottom="off", left="off", right="off", labelleft="off", labelbottom="on")
+    pyplot.tick_params(top="off", bottom="off", left="off", right="off",
+                       labelleft="off", labelbottom="on")
     pyplot.bar(df.index, df["additions"], label="additions")
     pyplot.bar(df.index, df["removals"], label="removals")
     pyplot.plot(df.index, effective, "black", label="effective")

+ 5 - 9
internal/burndown/file.go

@@ -254,16 +254,12 @@ func (file *File) Merge(day int, others... *File) {
 			if ol & TreeMergeMark == TreeMergeMark {
 				continue
 			}
-			// the following should happen rarely:
-			// l & TreeMergeMark != TreeMergeMark && l != ol
-			if l & TreeMergeMark == TreeMergeMark || l > ol {
-				// 1 - the line is merged in myself and exists in other
-				// 2 - the same line introduced in different branches,
-				// consider the oldest version as the ground truth
-				//
-				// in case with (2) we should decrease the "future" counter,
-				// but that really poisons the analysis
+			if l & TreeMergeMark == TreeMergeMark || l & TreeMergeMark > ol & TreeMergeMark {
+				// the line is merged in myself and exists in other
+				// OR the same line introduced in different branches
+				// consider the oldest version as the ground truth in that case
 				myself[i] = ol
+				continue
 			}
 		}
 	}

+ 23 - 12
internal/core/pipeline.go

@@ -145,14 +145,16 @@ type ResultMergeablePipelineItem interface {
 
 // CommonAnalysisResult holds the information which is always extracted at Pipeline.Run().
 type CommonAnalysisResult struct {
-	// Time of the first commit in the analysed sequence.
+	// BeginTime is the time of the first commit in the analysed sequence.
 	BeginTime int64
-	// Time of the last commit in the analysed sequence.
+	// EndTime is the time of the last commit in the analysed sequence.
 	EndTime int64
-	// The number of commits in the analysed sequence.
+	// CommitsNumber is the number of commits in the analysed sequence.
 	CommitsNumber int
-	// The duration of Pipeline.Run().
+	// RunTime is the duration of Pipeline.Run().
 	RunTime time.Duration
+	// RunTimePerItem is the time elapsed by each PipelineItem.
+	RunTimePerItem map[string]float64
 }
 
 // BeginTimeAsTime converts the UNIX timestamp of the beginning to Go time.
@@ -180,6 +182,9 @@ func (car *CommonAnalysisResult) Merge(other *CommonAnalysisResult) {
 	}
 	car.CommitsNumber += other.CommitsNumber
 	car.RunTime += other.RunTime
+	for key, val := range other.RunTimePerItem {
+		car.RunTimePerItem[key] += val
+	}
 }
 
 // FillMetadata copies the data to a Protobuf message.
@@ -188,6 +193,7 @@ func (car *CommonAnalysisResult) FillMetadata(meta *pb.Metadata) *pb.Metadata {
 	meta.EndUnixTime = car.EndTime
 	meta.Commits = int32(car.CommitsNumber)
 	meta.RunTime = car.RunTime.Nanoseconds() / 1e6
+	meta.RunTimePerItem = car.RunTimePerItem
 	return meta
 }
 
@@ -197,10 +203,11 @@ type Metadata = pb.Metadata
 // MetadataToCommonAnalysisResult copies the data from a Protobuf message.
 func MetadataToCommonAnalysisResult(meta *Metadata) *CommonAnalysisResult {
 	return &CommonAnalysisResult{
-		BeginTime:     meta.BeginUnixTime,
-		EndTime:       meta.EndUnixTime,
-		CommitsNumber: int(meta.Commits),
-		RunTime:       time.Duration(meta.RunTime * 1e6),
+		BeginTime:      meta.BeginUnixTime,
+		EndTime:        meta.EndUnixTime,
+		CommitsNumber:  int(meta.Commits),
+		RunTime:        time.Duration(meta.RunTime * 1e6),
+		RunTimePerItem: meta.RunTimePerItem,
 	}
 }
 
@@ -608,6 +615,7 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 	// we will need rootClone if there is more than one root branch
 	rootClone := cloneItems(pipeline.items, 1)[0]
 	var newestTime int64
+	runTimePerItem := map[string]float64{}
 
 	commitIndex := 0
 	for index, step := range plan {
@@ -627,7 +635,9 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 					plan[index+1].Commit.Hash == step.Commit.Hash),
 			}
 			for _, item := range branches[firstItem] {
+				startTime := time.Now()
 				update, err := item.Consume(state)
+				runTimePerItem[item.Name()] += time.Now().Sub(startTime).Seconds()
 				if err != nil {
 					log.Printf("%s failed on commit #%d (%d) %s\n",
 						item.Name(), commitIndex + 1, index + 1, step.Commit.Hash.String())
@@ -675,10 +685,11 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 	}
 	onProgress(progressSteps, progressSteps)
 	result[nil] = &CommonAnalysisResult{
-		BeginTime:     plan[0].Commit.Committer.When.Unix(),
-		EndTime:       newestTime,
-		CommitsNumber: len(commits),
-		RunTime:       time.Since(startRunTime),
+		BeginTime:      plan[0].Commit.Committer.When.Unix(),
+		EndTime:        newestTime,
+		CommitsNumber:  len(commits),
+		RunTime:        time.Since(startRunTime),
+		RunTimePerItem: runTimePerItem,
 	}
 	return result, nil
 }

+ 12 - 3
internal/core/pipeline_test.go

@@ -224,6 +224,10 @@ func TestPipelineRun(t *testing.T) {
 	assert.Equal(t, common.EndTime, int64(1481719198))
 	assert.Equal(t, common.CommitsNumber, 1)
 	assert.True(t, common.RunTime.Nanoseconds()/1e6 < 100)
+	assert.Len(t, common.RunTimePerItem, 1)
+	for key, val := range common.RunTimePerItem {
+		assert.True(t, val >= 0, key)
+	}
 	assert.True(t, item.DepsConsumed)
 	assert.True(t, item.CommitMatches)
 	assert.True(t, item.IndexMatches)
@@ -405,27 +409,32 @@ func TestPipelineError(t *testing.T) {
 
 func TestCommonAnalysisResultMerge(t *testing.T) {
 	c1 := CommonAnalysisResult{
-		BeginTime: 1513620635, EndTime: 1513720635, CommitsNumber: 1, RunTime: 100}
+		BeginTime: 1513620635, EndTime: 1513720635, CommitsNumber: 1, RunTime: 100,
+	    RunTimePerItem: map[string]float64{"one": 1, "two": 2}}
 	assert.Equal(t, c1.BeginTimeAsTime().Unix(), int64(1513620635))
 	assert.Equal(t, c1.EndTimeAsTime().Unix(), int64(1513720635))
 	c2 := CommonAnalysisResult{
-		BeginTime: 1513620535, EndTime: 1513730635, CommitsNumber: 2, RunTime: 200}
+		BeginTime: 1513620535, EndTime: 1513730635, CommitsNumber: 2, RunTime: 200,
+		RunTimePerItem: map[string]float64{"two": 4, "three": 8}}
 	c1.Merge(&c2)
 	assert.Equal(t, c1.BeginTime, int64(1513620535))
 	assert.Equal(t, c1.EndTime, int64(1513730635))
 	assert.Equal(t, c1.CommitsNumber, 3)
 	assert.Equal(t, c1.RunTime.Nanoseconds(), int64(300))
+	assert.Equal(t, c1.RunTimePerItem, map[string]float64{"one": 1, "two": 6, "three": 8})
 }
 
 func TestCommonAnalysisResultMetadata(t *testing.T) {
 	c1 := &CommonAnalysisResult{
-		BeginTime: 1513620635, EndTime: 1513720635, CommitsNumber: 1, RunTime: 100 * 1e6}
+		BeginTime: 1513620635, EndTime: 1513720635, CommitsNumber: 1, RunTime: 100 * 1e6,
+		RunTimePerItem: map[string]float64{"one": 1, "two": 2}}
 	meta := &pb.Metadata{}
 	c1 = MetadataToCommonAnalysisResult(c1.FillMetadata(meta))
 	assert.Equal(t, c1.BeginTimeAsTime().Unix(), int64(1513620635))
 	assert.Equal(t, c1.EndTimeAsTime().Unix(), int64(1513720635))
 	assert.Equal(t, c1.CommitsNumber, 1)
 	assert.Equal(t, c1.RunTime.Nanoseconds(), int64(100*1e6))
+	assert.Equal(t, c1.RunTimePerItem, map[string]float64{"one": 1, "two": 2})
 }
 
 func TestConfigurationOptionTypeString(t *testing.T) {

+ 79 - 67
internal/pb/pb.pb.go

@@ -58,6 +58,8 @@ type Metadata struct {
 	Commits int32 `protobuf:"varint,6,opt,name=commits,proto3" json:"commits,omitempty"`
 	// duration of the analysis in milliseconds
 	RunTime int64 `protobuf:"varint,7,opt,name=run_time,json=runTime,proto3" json:"run_time,omitempty"`
+	// time taken by each pipeline item in seconds
+	RunTimePerItem map[string]float64 `protobuf:"bytes,8,rep,name=run_time_per_item,json=runTimePerItem" json:"run_time_per_item,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"fixed64,2,opt,name=value,proto3"`
 }
 
 func (m *Metadata) Reset()                    { *m = Metadata{} }
@@ -114,6 +116,13 @@ func (m *Metadata) GetRunTime() int64 {
 	return 0
 }
 
+func (m *Metadata) GetRunTimePerItem() map[string]float64 {
+	if m != nil {
+		return m.RunTimePerItem
+	}
+	return nil
+}
+
 type BurndownSparseMatrixRow struct {
 	// the first `len(column)` elements are stored,
 	// the rest `number_of_columns - len(column)` values are zeros
@@ -615,71 +624,74 @@ func init() {
 func init() { proto.RegisterFile("pb.proto", fileDescriptorPb) }
 
 var fileDescriptorPb = []byte{
-	// 1053 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0xdf, 0x6e, 0x1b, 0xc5,
-	0x17, 0xd6, 0x66, 0xfd, 0xf7, 0xac, 0x9d, 0xb4, 0xf3, 0xeb, 0xaf, 0xd9, 0x06, 0xb5, 0x98, 0x25,
-	0x80, 0xa1, 0x65, 0x8b, 0xdc, 0x1b, 0x08, 0x37, 0x24, 0x2e, 0x15, 0xbd, 0x08, 0x48, 0xe3, 0x14,
-	0x2e, 0xad, 0xf1, 0xee, 0x24, 0x5e, 0x58, 0xcf, 0xac, 0x66, 0x76, 0x93, 0xf8, 0x65, 0xb8, 0x43,
-	0x42, 0x48, 0x88, 0x0b, 0x5e, 0x80, 0xd7, 0xe0, 0x19, 0x78, 0x09, 0x34, 0xff, 0xec, 0xb5, 0xe5,
-	0x54, 0xdc, 0xcd, 0x39, 0xe7, 0xfb, 0xce, 0x9c, 0xf9, 0xce, 0x99, 0xd9, 0x85, 0x4e, 0x31, 0x8b,
-	0x0b, 0xc1, 0x4b, 0x1e, 0xfd, 0xed, 0x41, 0xe7, 0x9c, 0x96, 0x24, 0x25, 0x25, 0x41, 0x21, 0xb4,
-	0xaf, 0xa9, 0x90, 0x19, 0x67, 0xa1, 0x37, 0xf0, 0x86, 0x4d, 0xec, 0x4c, 0x84, 0xa0, 0x31, 0x27,
-	0x72, 0x1e, 0xee, 0x0d, 0xbc, 0x61, 0x17, 0xeb, 0x35, 0x7a, 0x02, 0x20, 0x68, 0xc1, 0x65, 0x56,
-	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xff, 0x7e, 0x55, 0x2d, 0x51, 0x92, 0x09, 0x00, 0x00,
+	// 1098 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0xcd, 0x92, 0xdb, 0xc4,
+	0x13, 0x2f, 0x59, 0xfe, 0x6c, 0xd9, 0xbb, 0xc9, 0x24, 0xff, 0xac, 0xe2, 0x7f, 0x6d, 0x30, 0x22,
+	0x80, 0x21, 0x41, 0xa1, 0x9c, 0x0b, 0x84, 0x0b, 0x1b, 0x87, 0x54, 0x72, 0x58, 0xa0, 0xc6, 0x1b,
+	0x38, 0xaa, 0x64, 0x69, 0x76, 0x2d, 0xb0, 0x66, 0x54, 0x33, 0xd2, 0xee, 0xfa, 0x65, 0xb8, 0x51,
+	0x45, 0x51, 0x45, 0x71, 0xe0, 0x05, 0x78, 0x1a, 0x2e, 0xbc, 0x04, 0x35, 0x5f, 0xb6, 0xec, 0xf2,
+	0x06, 0x6e, 0xea, 0xee, 0x5f, 0xf7, 0x74, 0xff, 0xba, 0xa7, 0x47, 0xd0, 0x2d, 0xe6, 0x61, 0xc1,
+	0x59, 0xc9, 0x82, 0xbf, 0x1a, 0xd0, 0x3d, 0x25, 0x65, 0x9c, 0xc6, 0x65, 0x8c, 0x7c, 0xe8, 0x5c,
+	0x12, 0x2e, 0x32, 0x46, 0x7d, 0x67, 0xe4, 0x8c, 0x5b, 0xd8, 0x8a, 0x08, 0x41, 0x73, 0x11, 0x8b,
+	0x85, 0xdf, 0x18, 0x39, 0xe3, 0x1e, 0x56, 0xdf, 0xe8, 0x01, 0x00, 0x27, 0x05, 0x13, 0x59, 0xc9,
+	0xf8, 0xca, 0x77, 0x95, 0xa5, 0xa6, 0x41, 0x1f, 0xc0, 0xe1, 0x9c, 0x5c, 0x64, 0x34, 0xaa, 0x68,
+	0x76, 0x1d, 0x95, 0x59, 0x4e, 0xfc, 0xe6, 0xc8, 0x19, 0x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 0x5a, 0xbe, 0xf3, 0xb6, 0xfa, 0x27, 0x7c, 0xfa, 0x4f, 0x00, 0x00, 0x00,
+	0xff, 0xff, 0x0a, 0xd8, 0x24, 0x36, 0x1f, 0x0a, 0x00, 0x00,
 }

+ 2 - 0
internal/pb/pb.proto

@@ -15,6 +15,8 @@ message Metadata {
     int32 commits = 6;
     // duration of the analysis in milliseconds
     int64 run_time = 7;
+    // time taken by each pipeline item in seconds
+    map<string, double> run_time_per_item = 8;
 }
 
 message BurndownSparseMatrixRow {

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 99 - 43
internal/pb/pb_pb2.py


+ 22 - 8
labours.py

@@ -24,7 +24,7 @@ import yaml
 
 if sys.version_info[0] < 3:
     # OK, ancients, I will support Python 2, but you owe me a beer
-    input = raw_input
+    input = raw_input  # noqa: F821
 
 
 PB_MESSAGES = {
@@ -54,7 +54,7 @@ def parse_args():
     parser.add_argument("--couples-tmp-dir", help="Temporary directory to work with couples.")
     parser.add_argument("-m", "--mode",
                         choices=["project", "file", "person", "churn_matrix", "ownership",
-                                 "couples", "shotness", "sentiment", "all"],
+                                 "couples", "shotness", "sentiment", "all", "run_times"],
                         help="What to plot.")
     parser.add_argument(
         "--resample", default="year",
@@ -131,6 +131,9 @@ class YamlReader(Reader):
             sys.exit(1)
         self.data = data
 
+    def get_run_times(self):
+        return {}
+
     def get_name(self):
         return self.data["hercules"]["repository"]
 
@@ -249,6 +252,9 @@ class ProtobufReader(Reader):
             self.contents[key] = msg = cls()
             msg.ParseFromString(val)
 
+    def get_run_times(self):
+        return {key: val for key, val in self.data.header.run_time_per_item.items()}
+
     def get_name(self):
         return self.data.header.repository
 
@@ -495,6 +501,7 @@ def load_burndown(header, name, matrix, resample):
     print(name, "lifetime index:", calculate_average_lifetime(matrix))
     finish = start + timedelta(days=matrix.shape[1] * sampling)
     if resample not in ("no", "raw"):
+        print("resampling to %s, please wait..." % resample)
         # Interpolate the day x day matrix.
         # Each day brings equal weight in the granularity.
         # Sampling's interpolation is linear.
@@ -641,7 +648,7 @@ def deploy_plot(title, output, style):
             pyplot.title(title, color=style)
         try:
             pyplot.tight_layout()
-        except:
+        except:  # noqa: E722
             print("Warning: failed to set the tight layout")
         pyplot.savefig(output, transparent=True)
     pyplot.clf()
@@ -831,6 +838,7 @@ def plot_ownership(args, repo, names, people, date_range, last):
         output = args.output
     deploy_plot("%s code ownership through time" % repo, output, args.style)
 
+
 IDEAL_SHARD_SIZE = 4096
 
 
@@ -965,7 +973,7 @@ class CORSWebServer(object):
 
         try:
             from http.server import HTTPServer, SimpleHTTPRequestHandler, test
-        except ImportError: # Python 2
+        except ImportError:  # Python 2
             from BaseHTTPServer import HTTPServer, test
             from SimpleHTTPServer import SimpleHTTPRequestHandler
 
@@ -974,9 +982,8 @@ class CORSWebServer(object):
                 HTTPServer.__init__(self, *args, **kwargs)
                 outer.server = self
 
-
         class CORSRequestHandler(SimpleHTTPRequestHandler):
-            def end_headers (self):
+            def end_headers(self):
                 self.send_header("Access-Control-Allow-Origin", "*")
                 SimpleHTTPRequestHandler.end_headers(self)
 
@@ -1118,7 +1125,6 @@ def show_sentiment_stats(args, name, resample, start, data):
     overall_neg = sum(2 * (d[1].Value - 0.5) for d in data if d[1].Value > 0.5)
     title = "%s sentiment +%.1f -%.1f δ=%.1f" % (
         name, overall_pos, overall_neg, overall_pos - overall_neg)
-    output = args.output
     deploy_plot(title, args.output, args.style)
 
 
@@ -1140,6 +1146,11 @@ def main():
                        "--shotness. Also check --languages - the output may be empty."
     sentiment_warning = "Sentiment stats were not collected. Re-run hercules with --sentiment."
 
+    def run_times():
+        rt = reader.get_run_times()
+        import pandas
+        print(pandas.to_timedelta(pandas.Series(rt).sort_values(ascending=False), unit="s"))
+
     def project_burndown():
         try:
             full_header = header + reader.get_burndown_parameters()
@@ -1224,7 +1235,9 @@ def main():
             return
         show_sentiment_stats(args, reader.get_name(), args.resample, reader.get_header()[0], data)
 
-    if args.mode == "project":
+    if args.mode == "run_times":
+        run_times()
+    elif args.mode == "project":
         project_burndown()
     elif args.mode == "file":
         files_burndown()
@@ -1260,5 +1273,6 @@ def main():
             pass
         web_server.stop()
 
+
 if __name__ == "__main__":
     sys.exit(main())