core/src/main/java/com/orientechnologies/orient/core/sql/parser/OProfileStorageStatement.java
@Override public OResultSet executeSimple(OCommandContext ctx) {
    OResultInternal result = new OResultInternal();
    result.setProperty("operation", "optimize database");

    OStorage storage = ((ODatabaseInternal) ctx.getDatabase()).getStorage();

    if (on) {
      // activate the profiler
      ((OAbstractPaginatedStorage) storage).startGatheringPerformanceStatisticForCurrentThread();
      result.setProperty("value", "on");
    } else {
      // stop the profiler and return the stats
      final OSessionStoragePerformanceStatistic performanceStatistic = ((OAbstractPaginatedStorage) storage)
          .completeGatheringPerformanceStatisticForCurrentThread();

      result.setProperty("value", "off");
      if (performanceStatistic != null) {
        result.setProperty("result", performanceStatistic.toDocument());
      } else {
        result.setProperty("result", "error");
        result.setProperty("errorMessage", "profiling of storage was not started");
      }
    }

    OInternalResultSet rs = new OInternalResultSet();
    rs.add(result);
    return rs;
  }
@Override public OResultSet executeSimple(OCommandContext ctx) {
    OResultInternal result = new OResultInternal();
    result.setProperty("operation", "optimize database");

    OStorage storage = ((ODatabaseInternal) ctx.getDatabase()).getStorage();

    if (on) {
      // activate the profiler
      ((OAbstractPaginatedStorage) storage).startGatheringPerformanceStatisticForCurrentThread();
      result.setProperty("value", "on");
    } else {
      // stop the profiler and return the stats
      final OSessionStoragePerformanceStatistic performanceStatistic = ((OAbstractPaginatedStorage) storage)
          .completeGatheringPerformanceStatisticForCurrentThread();

      result.setProperty("value", "off");
      if (performanceStatistic != null) {
        result.setProperty("result", performanceStatistic.toDocument());
      } else {
        result.setProperty("result", "error");
        result.setProperty("errorMessage", "profiling of storage was not started");
      }
    }

    OInternalResultSet rs = new OInternalResultSet();
    rs.add(result);
    return rs;
  }
new execution logic