UsbTdAllocatorTest.Mod 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. MODULE UsbTdAllocatorTest; (** AUTHOR "Timothée Martiel"; PURPOSE "Testing for UsbTdAllocator"; *)
  2. IMPORT Kernel, Commands, UsbVarTdAlloc;
  3. CONST
  4. Nb = 1024 * 1;
  5. Size = 32 * 32;
  6. (**
  7. * Measure average allocation and freeing speed for the size 16.
  8. * Usage:
  9. * UsbTdAllocatorTest.Benchmark size ~
  10. *)
  11. PROCEDURE Benchmark * (context: Commands.Context);
  12. VAR
  13. tds: ARRAY Nb OF ADDRESS;
  14. t: Kernel.MilliTimer;
  15. alloc: UsbVarTdAlloc.Allocator;
  16. i, size, time: LONGINT;
  17. BEGIN
  18. context.out.String("Repetitions: ");
  19. context.out.Int(Nb, 0);
  20. context.out.Ln;
  21. context.out.Update;
  22. NEW(alloc, 4096, 32);
  23. context.out.String("Allocating TDs");
  24. size := 64;
  25. Kernel.SetTimer(t, 30000);
  26. FOR i := 0 TO Nb - 1 DO
  27. tds[i] := alloc.Allocate(size);
  28. END;
  29. time := Kernel.Elapsed(t);
  30. context.out.String("... done");
  31. context.out.Ln;
  32. context.out.String("elapsed time: ");
  33. context.out.Int(time, 0);
  34. context.out.Ln;
  35. context.out.Update;
  36. context.out.String("Freeing TDs");
  37. Kernel.SetTimer(t, 30000);
  38. FOR i := 0 TO Nb - 1 DO
  39. alloc.Free(tds[i], size);
  40. END;
  41. time := Kernel.Elapsed(t);
  42. context.out.String("... done");
  43. context.out.Ln;
  44. context.out.String("elapsed time: ");
  45. context.out.Int(time, 0);
  46. context.out.Ln;
  47. context.out.Update
  48. END Benchmark;
  49. PROCEDURE Test * (context: Commands.Context);
  50. BEGIN
  51. context.out.String("Test command");
  52. context.out.Ln;
  53. context.out.Update
  54. END Test;
  55. END UsbTdAllocatorTest.
  56. UsbTdAllocatorTest.Benchmark ~
  57. SystemTools.Free UsbTdAllocatorTest UsbTdAllocator ~
  58. Compiler.Compile -b=ARM --traceModule=Trace --mergeSections
  59. basel/USB/UsbVarTdAlloc.Mod
  60. basel/USB/UsbTdAllocatorTest.Mod
  61. ~