# perldoc > DBI::ProfileDumper

---
type: CommandReference
command: DBI::ProfileDumper
mode: perldoc
section: 
source: perldoc
---

## Quick Reference

- `DBI_PROFILE=2/DBI::ProfileDumper program.pl` — profile program using environment variable
- `$dbh->{Profile} = "!Statement/DBI::ProfileDumper"` — enable profiling with default file
- `$dbh->{Profile} = "!Statement/DBI::ProfileDumper/File:dbi.prof"` — specify output file
- `$dbh->{Profile} = DBI::ProfileDumper->new(Path => [ '!Statement' ], File => 'dbi.prof')` — object-oriented activation
- `$profile->flush_to_disk()` — flush collected data to disk
- `$profile->empty()` — clear data without writing
- `$filename = $profile->filename()` — get or set output filename
- `dbiprof` — analyze the generated profile file

## Name

`DBI::ProfileDumper` — profile DBI usage and output data to a file

## Synopsis

Perl code activation:

perl
use DBI;
$dbh->{Profile} = "!Statement/DBI::ProfileDumper";
$dbh->{Profile} = "!Statement/DBI::ProfileDumper/File:dbi.prof";
use DBI::ProfileDumper;
$dbh->{Profile} = DBI::ProfileDumper->new(
    Path => [ '!Statement' ],
    File => 'dbi.prof'
);
$dbh->{Profile} = DBI::ProfileDumper->new(
    Path => [ "foo", "bar" ],
    File => 'dbi.prof',
);
Environment variable:

shell
DBI_PROFILE=2/DBI::ProfileDumper program.pl
Then analyze:

shell
dbiprof
## Options / Methods

- `flush_to_disk()` — Flushes all collected profile data to disk and empties the Data hash. Returns the filename written. File is locked while writing. Can be called multiple times.
- `empty()` — Clears the Data hash without writing to disk.
- `filename()` — Get or set the filename. Can be a CODE reference; the code will be called with the profile object as its first argument.

## Examples

Activation via environment variable:

shell
export DBI_PROFILE="!Statement/DBI::ProfileDumper"
perl my_program.pl
Activation from within code:

perl
use DBI::ProfileDumper;
$dbh->{Profile} = DBI::ProfileDumper->new(
    Path => [ '!Statement' ],
    File => 'dbi.prof'
);
Flush data to disk:

perl
my $profile = $dbh->{Profile};
$profile->flush_to_disk();
## See Also

- [DBI::Profile](https://www.chedong.com/phpMan.php/perldoc/DBI%3A%3AProfile/markdown)
- [DBI::ProfileData](https://www.chedong.com/phpMan.php/perldoc/DBI%3A%3AProfileData/markdown)
- [DBI::ProfileDumper::Apache](https://www.chedong.com/phpMan.php/perldoc/DBI%3A%3AProfileDumper%3A%3AApache/markdown)
- `dbiprof` (command-line tool)

## Exit Codes

Not documented.