Aptana Studio ヘルプ > はじめに > Inspecting and Debugging with Firebug

Profiling code performance

This page describes how to use the Firebug extension for Firefox to profile code performance for a web page.

Contents

Introduction

The Firebug console provides you with three ways to detect performance problems in your code:

Instructions

Determining how long a function takes to execute

The simplest way to identify a performance issue is to determine how long a suspicious function takes to run. To determine how long a function is taking to execute:

  1. Add a console.time() function just before the function.
  2. Add a console.timeEnd() function just after the function.

This will give you the start and end time for the execution of the function.

Running a code profile on a script

If you have no idea which functions are causing performance issues in your code, you can create a Profile report in Firebug to help you troubleshoot.

To create a Profile report:

  1. Click the Image:iconFirebugScript.png tab.
  2. Click the Image:iconFirebugProfile.png button to start the profiler.
  3. Click the Image:iconFirebugProfile.png button again to stop the profiler.

The console will display the Profile report for your code.

Running a code profile on specific blocks of code

You can also create a targeted profile report by creating a profile for a specific block of code. To create a profile for a specific block of code:

  1. Add a console.profile() function just before the function.
  2. Add a console.profileEnd() function just after the function.

Related Topics