Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

testspecgram.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. function testspecgram(data)
  2. %cd 'C:\Documents and Settings\Admin\Desktop\';
  3. %data=wavread('bird109_26519_on_Aug_19_16_33.wav');
  4. params.tapers = [3 5];
  5. params.fpass = [100 20000];
  6. params.Fs = 44100;
  7. params.pad = 2;
  8. max_time =10; % seconds per run
  9. max_tapers = 150;
  10. increment = 1.5;
  11. profile on
  12. nsamples = 1000;
  13. if 1
  14. slow_results = [];
  15. while 1
  16. tic
  17. [S,t,f] = mtspecgramc_slow( data(1:nsamples), [0.01 0.001], params );
  18. time = toc;
  19. result = [nsamples time];
  20. fprintf( 'ran %d samples in %d seconds\n',nsamples, time );
  21. slow_results = [slow_results ;result];
  22. if time > max_time
  23. break
  24. end
  25. nsamples = round(nsamples * increment);
  26. end
  27. slow_results
  28. fig=figure();
  29. ax=axes('XScale','log','YScale','log');
  30. axes(ax);
  31. h=line( 'Xdata',slow_results(:,1),'Ydata',slow_results(:,2),'Marker','*');
  32. xlabel('number of samples')
  33. ylabel('time');
  34. title('Original mtspecgramc');
  35. grid on
  36. drawnow;
  37. saveas(fig,'datalength_slow.png');
  38. nsamples = 1000;
  39. fast_results = [];
  40. while 1
  41. tic
  42. [S,t,f] = mtspecgramc( data(1:nsamples), [0.01 0.001], params );
  43. time = toc;
  44. result = [nsamples time];
  45. fprintf( 'ran %d samples in %d seconds\n',nsamples, time );
  46. fast_results = [fast_results ;result];
  47. if time > max_time
  48. break
  49. end
  50. nsamples = round(nsamples * increment);
  51. end
  52. fast_results
  53. fig=figure();
  54. ax=axes('XScale','log','YScale','log');
  55. axes(ax);
  56. h=line( 'Xdata',fast_results(:,1),'Ydata',fast_results(:,2),'Marker','*');
  57. xlabel('number of samples')
  58. ylabel('time');
  59. title('Modified mtspecgramc - preallocate space');
  60. grid on
  61. drawnow;
  62. saveas(fig,'datalength_fast.png');
  63. compare = [];
  64. n = 1;
  65. while n <= min(length(slow_results(:,1)),length(fast_results(:,1)))
  66. compare_one = [slow_results(n,1) slow_results(n,2)/fast_results(n,2)];
  67. compare = [compare ;compare_one];
  68. n = n + 1;
  69. end
  70. compare
  71. fig=figure();
  72. ax=axes('XScale','log','YScale','lin');
  73. axes(ax);
  74. h=line( 'Xdata',compare(:,1),'Ydata',compare(:,2),'Marker','*');
  75. title('Preallocation slowdown/speedup of mtspecgramc');
  76. xlabel('number of samples')
  77. ylabel('speedup');
  78. grid on
  79. drawnow;
  80. saveas(fig,'speedup.png');
  81. end;
  82. nsamples=10000;
  83. results = [];
  84. n = 1;
  85. while 1
  86. tic
  87. params.tapers = [n (2*n-1)];
  88. [S,t,f] = mtspecgramc( data(1:nsamples), [0.01 0.001], params );
  89. time = toc;
  90. result = [params.tapers(2) time];
  91. fprintf( 'ran %d samples in %d seconds with tapers %d %d\n',nsamples, time,params.tapers(1),params.tapers(2) );
  92. results = [results ;result];
  93. if time > max_time || params.tapers(2) > max_tapers
  94. break
  95. end
  96. n = round(n * increment);
  97. end
  98. fig=figure();
  99. ax=axes('XScale','log','YScale','log');
  100. axes(ax);
  101. h=line( 'Xdata',results(:,1),'Ydata',results(:,2),'Marker','*');
  102. xlabel('tapers')
  103. ylabel('time');
  104. drawnow;
  105. saveas(fig,'tapers.png');
  106. stats = profile('info')