Skip to content

Commit 47ed220

Browse files
committed
add timer
1 parent 6c466ab commit 47ed220

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/drivers/ncmpio/ncmpio_close.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,24 @@ ncmpio_free_NC(NC *ncp)
4040
{
4141
int rank;
4242
MPI_Comm_rank(ncp->comm, &rank);
43+
double start_time = MPI_Wtime();
4344

4445
if (ncp == NULL) return;
4546

4647
ncmpio_free_NC_dimarray(&ncp->dims);
4748
// if (rank == 0)
4849
// printf("ncmpio_free_NC free() count after ncmpio_free_NC_dimarray: %d\n", free_counter);
49-
50-
// ncmpio_free_NC_attrarray(&ncp->attrs);
50+
double dim_free_time = MPI_Wtime() - start_time;
51+
ncmpio_free_NC_attrarray(&ncp->attrs);
5152
// if (rank == 0)
5253
// printf("ncmpio_free_NC free() count after ncmpio_free_NC_attarray: %d\n", free_counter);
54+
start_time = MPI_Wtime();
5355
ncmpio_free_NC_vararray(&ncp->vars);
56+
double other_start = MPI_Wtime();
57+
5458
// if (rank == 0)
5559
// printf("ncmpio_free_NC free() count after ncmpio_free_NC_vararray: %d\n", free_counter);
60+
double var_free_time = MPI_Wtime() - start_time;
5661

5762
/* The only case that ncp->mpiinfo is MPI_INFO_NULL is when exiting endef
5863
* from a redef. All other cases reaching here are from ncmpi_close, in
@@ -65,7 +70,11 @@ ncmpio_free_NC(NC *ncp)
6570
if (ncp->abuf != NULL) NCI_Free(ncp->abuf);
6671
if (ncp->path != NULL) NCI_Free(ncp->path);
6772

73+
double other_free_time = MPI_Wtime() - other_start;
74+
6875
NCI_Free(ncp);
76+
if (rank == 0)
77+
printf("dim_free_time: %f, var_free_time: %f, other_free_time: %f\n", dim_free_time, var_free_time, other_free_time);
6978
}
7079

7180
/*----< ncmpio_close_files() >-----------------------------------------------*/
@@ -104,6 +113,7 @@ ncmpio_close(void *ncdp)
104113
{
105114
int err=NC_NOERR, status=NC_NOERR;
106115
NC *ncp = (NC*)ncdp;
116+
double close_start = MPI_Wtime();
107117

108118
if (NC_indef(ncp)) { /* currently in define mode */
109119
status = ncmpio__enddef(ncp, 0, 0, 0, 0); /* TODO: defaults */

0 commit comments

Comments
 (0)