You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

calcCTPS.ts 993B

12345678910111213141516171819202122232425
  1. // Define the function to calculate average CTPS
  2. function calculateAverageCTPS(N, start, end) {
  3. // Convert the times to Date objects, if they are not already
  4. const startTime = new Date(start);
  5. const endTime = new Date(end);
  6. // Calculate the time difference in seconds
  7. const timeDifferenceInSeconds = (endTime.getTime() - startTime.getTime()) / 1000;
  8. // Calculate the average CTPS
  9. const averageCTPS = N / timeDifferenceInSeconds;
  10. return averageCTPS;
  11. }
  12. // Example usage
  13. const count = 1000; // Example number of transactions
  14. const start = "2023-11-15T08:00:00Z"; // Start time of the first transaction
  15. const end = "2023-11-15T08:05:00Z"; // Finish time of the latest transaction
  16. // const tSend_TX1 = new Date('2024-11-15T12:00:00Z'); // Replace with actual end time
  17. // const tFin_latest_TXk = new Date('2024-11-15T11:00:00Z'); // Replace with actual send time
  18. const result = calculateAverageCTPS(count, start, end);
  19. console.log("Average CTPS:", result);