# Profiling code performance [edit]

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

## Introduction

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

- Determining how long a function takes to execute
- Running a code profile on a script
- Running a code profile on specific blocks of 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 tab.
2. Click the button to start the profiler.
3. Click the 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

- About Firebug
- Installing the Firebug extension
- Inspecting HTML
- Inspecting CSS
- Monitoring XMLHttpRequests
- Editing a web page
- Writing to the Firebug console
- Setting breakpoints in Firebug

Retrieved from "http://aptana.com/docs/index.php/Profiling_code_performance"

Category: AptanaHelp