code: public long calculateDuration() {
          if (!nodes.isEmpty()) {
              long endTime = 0;
  
              for (int i = 0; i < getNodes().size(); i++) {
                  Node node = getNodes().get(i);
                  long nodeEndTime = node.overallEndTime();
  
                  if (nodeEndTime > endTime) {
                      endTime = nodeEndTime;
                  }
              }
  
              return endTime - getNodes().get(0).getTimestamp();
          }
  
          return 0L;
      }
docs: This method returns the duration of the trace fragment.
  
  @return The duration (in microseconds), or 0 if no nodes defined