Guides and Sample Code


Instruments User Guide

On This Page

Export and Import Trace Data

Instruments offers a variety of ways to export and import data for consolidation, archival purposes, analysis within Instruments, and external analysis through other tools.

Export Trace Data

You can export data from a trace document to a comma-separated value (CSV) file format, a simple data file format supported by many apps, including most database and spreadsheet apps. By bringing data into another app, such as Numbers, you can manipulate it further, perform additional analysis, generate custom charts and graphs, compare it to other data, and more.

To export trace data in CSV format
  1. After profiling an app with a trace document, select the instrument containing the data you want to export.

    image: ../Art/instruments_trace_document_strategy_pane_selectedinstrument_2x.png
  2. Choose Instrument > Export Track for instrumentname.

    image: ../Art/instruments_instrument_menu_exporttrack_menuitem_2x.png
  3. Enter a name for the file.

    image: ../Art/instruments_exporttrackdata_dialog_2x.png
  4. Specify a destination for the file.

  5. Click Save.

Instruments exports the data for the most recent run of the selected instrument.

Import Data from a Device

An iOS device can be configured to log energy-related information, which you can then import into Instruments for analysis. See Log Energy Usage Directly on an iOS Device in Measure Energy Impact.

Import Data from the (sample) Command-Line Tool

If you use the sample command-line tool to do a statistical analysis of your app’s execution, you can import your sample data and view it in Instruments. Importing data from the sample tool creates a new trace document with the Sampler instrument and loads the sample data into the detail pane. Because the samples do not contain time stamp information, you can only view the data using outline mode in the detail pane. A new trace document is created based on the file you select.

To analyze an app using the sample tool
  1. Launch the Terminal app.

  2. Enter a sample command, such as:

    • sample ListerOSX -file ~/Desktop/SampleData.txt

    This example samples an app for 10 seconds (the default), and saves the results to a file on the desktop.

To import data from the sample tool into an Instruments profiling template
  1. Choose File > Import Data.

    image: ../Art/instruments_file_menu_importdata_menuitem_2x.png
  2. Locate your saved data.

  3. Choose Sampler from the “Choose Instrument to Import Data” pop-up menu at the bottom of the Import Trace window. If this pop-up menu isn’t visible, click the Options button to display it.

    image: ../Art/instruments_importdata_dialog_2x.png
  4. Click Open.

    A new trace document containing the Sampler instrument is created, and it’s populated with the data you imported.

    image: ../Art/instruments_trace_document_importedsamplerdata_2x.png