# Package @google-cloud/profiler (5.0.3)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [5.0.3 (latest)](https://docs.cloud.google.com/nodejs/docs/reference/profiler/latest/overview)
- [5.0.2](https://docs.cloud.google.com/nodejs/docs/reference/profiler/5.0.2/overview)
- [4.1.5](https://docs.cloud.google.com/nodejs/docs/reference/profiler/4.1.5/overview)

## Functions

### createProfiler(config)

    export declare function createProfiler(config?: Config): Promise

Initializes the config, and starts heap profiler if the heap profiler is needed. Returns a profiler if creation is successful. Otherwise, returns rejected promise.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `config` | `Config` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Promise<Profiler>` |   |

### nodeVersionOkay(version)

    export declare function nodeVersionOkay(version: string | semver.SemVer): boolean;

Returns true if the version passed in satifised version requirements specified in the profiler's package.json.

Exported for testing.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `version` | `string | semver.SemVer` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `boolean` |   |

### start(config)

    export declare function start(config?: Config): Promise

Starts the profiling agent and returns a promise. If any error is encountered when configuring the profiler the promise will be rejected. Resolves when profiling is started.

config - Config describing configuration for profiling.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `config` | `Config` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Promise<void>` |   |

#### Examples

profiler.start();

profiler.start(config);

### startLocal(config)

    export declare function startLocal(config?: Config): Promise

For debugging purposes. Collects profiles and discards the collected profiles.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `config` | `Config` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Promise<void>` |   |