|
|
|
|
361
|
f, err = fetchURL(sourceURL, timeout)
|
361
|
f, err = fetchURL(sourceURL, timeout)
|
362
|
src = sourceURL
|
362
|
src = sourceURL
|
363
|
} else {
|
363
|
} else {
|
364
|
- f, err = profileProtoReader(source)
|
|
|
|
|
364
|
+ f, err = profileProtoReader(source, ui)
|
365
|
}
|
365
|
}
|
366
|
if err == nil {
|
366
|
if err == nil {
|
367
|
defer f.Close()
|
367
|
defer f.Close()
|
|
|
|
|
387
|
// the file to profile.proto format. It returns a ReadCloser to the
|
387
|
// the file to profile.proto format. It returns a ReadCloser to the
|
388
|
// profile.proto data; however, if the file contents were unknown or conversion
|
388
|
// profile.proto data; however, if the file contents were unknown or conversion
|
389
|
// failed, it may still not be a valid profile.proto.
|
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
|
sourceFile, openErr := os.Open(path)
|
391
|
sourceFile, openErr := os.Open(path)
|
392
|
if openErr != nil {
|
392
|
if openErr != nil {
|
393
|
return nil, openErr
|
393
|
return nil, openErr
|
|
|
|
|
407
|
}
|
407
|
}
|
408
|
if bytes.Equal(actualHeader, perfHeader) {
|
408
|
if bytes.Equal(actualHeader, perfHeader) {
|
409
|
sourceFile.Close()
|
409
|
sourceFile.Close()
|
410
|
- profileFile, convertErr := convertPerfData(path)
|
|
|
|
|
410
|
+ profileFile, convertErr := convertPerfData(path, ui)
|
411
|
if convertErr != nil {
|
411
|
if convertErr != nil {
|
412
|
return nil, convertErr
|
412
|
return nil, convertErr
|
413
|
}
|
413
|
}
|
|
|
|
|
420
|
// using the perf_to_profile tool. It prints the stderr and stdout of
|
420
|
// using the perf_to_profile tool. It prints the stderr and stdout of
|
421
|
// perf_to_profile to the stderr and stdout of this process, then returns the
|
421
|
// perf_to_profile to the stderr and stdout of this process, then returns the
|
422
|
// path to a file containing the profile.proto formatted data.
|
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
|
randomBytes := make([]byte, 32)
|
427
|
randomBytes := make([]byte, 32)
|
425
|
_, randErr := rand.Read(randomBytes)
|
428
|
_, randErr := rand.Read(randomBytes)
|
426
|
if randErr != nil {
|
429
|
if randErr != nil {
|