Przeglądaj źródła

Lets client know that the perf.data conversion may take a few minutes.

Wade Simba Khadder 8 lat temu
rodzic
commit
afe48f0df8
1 zmienionych plików z 7 dodań i 4 usunięć
  1. 7
    4
      internal/driver/fetch.go

+ 7
- 4
internal/driver/fetch.go Wyświetl plik

@@ -361,7 +361,7 @@ func fetch(source string, duration, timeout time.Duration, ui plugin.UI) (p *pro
361 361
 		f, err = fetchURL(sourceURL, timeout)
362 362
 		src = sourceURL
363 363
 	} else {
364
-		f, err = profileProtoReader(source)
364
+		f, err = profileProtoReader(source, ui)
365 365
 	}
366 366
 	if err == nil {
367 367
 		defer f.Close()
@@ -387,7 +387,7 @@ func fetchURL(source string, timeout time.Duration) (io.ReadCloser, error) {
387 387
 // the file to profile.proto format. It returns a ReadCloser to the
388 388
 // profile.proto data; however, if the file contents were unknown or conversion
389 389
 // failed, it may still not be a valid profile.proto.
390
-func profileProtoReader(path string) (io.ReadCloser, error) {
390
+func profileProtoReader(path string, ui plugin.UI) (io.ReadCloser, error) {
391 391
 	sourceFile, openErr := os.Open(path)
392 392
 	if openErr != nil {
393 393
 		return nil, openErr
@@ -407,7 +407,7 @@ func profileProtoReader(path string) (io.ReadCloser, error) {
407 407
 	}
408 408
 	if bytes.Equal(actualHeader, perfHeader) {
409 409
 		sourceFile.Close()
410
-		profileFile, convertErr := convertPerfData(path)
410
+		profileFile, convertErr := convertPerfData(path, ui)
411 411
 		if convertErr != nil {
412 412
 			return nil, convertErr
413 413
 		}
@@ -420,7 +420,10 @@ func profileProtoReader(path string) (io.ReadCloser, error) {
420 420
 // using the perf_to_profile tool. It prints the stderr and stdout of
421 421
 // perf_to_profile to the stderr and stdout of this process, then returns the
422 422
 // path to a file containing the profile.proto formatted data.
423
-func convertPerfData(perfPath string) (string, error) {
423
+func convertPerfData(perfPath string, ui plugin.UI) (string, error) {
424
+	ui.Print(fmt.Sprintf(
425
+		"Converting %s to a profile.proto... (May take a few minutes)",
426
+		perfPath))
424 427
 	randomBytes := make([]byte, 32)
425 428
 	_, randErr := rand.Read(randomBytes)
426 429
 	if randErr != nil {