Advertisement
rockdrilla

(da)sh substring matching speed tests

Apr 18th, 2018
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | None | 0 0
  1. substrcmp() {
  2.     local x y z
  3.     x=${#1}; y=${1#*$2}; z=${#y}
  4.     [ $x -ne $z ]
  5. }
  6.  
  7.  
  8.  
  9. date --rfc-3339=ns
  10. for i in $(seq 1 20000); do
  11.     echo "abc${i}def%Fzyx" | grep -Fqe '%F'
  12. done
  13. date --rfc-3339=ns
  14.  
  15. # 2018-04-19 00:39:20.956273584
  16. # 2018-04-19 00:39:36.707469684
  17.  
  18.  
  19.  
  20. date --rfc-3339=ns
  21. for i in $(seq 1 20000); do
  22.     substrcmp "abc${i}def%Fzyx" '%F'
  23. done
  24. date --rfc-3339=ns
  25.  
  26. # 2018-04-19 00:39:20.863260849
  27. # 2018-04-19 00:39:20.955660959
  28.  
  29.  
  30.  
  31. date --rfc-3339=ns
  32. for i in $(seq 1 2000); do
  33.     echo "abc${i}def%Fzyx" | grep -Fqe '%F'
  34. done
  35. date --rfc-3339=ns
  36.  
  37. # 2018-04-19 00:40:49.657582863
  38. # 2018-04-19 00:40:51.202037260
  39.  
  40.  
  41.  
  42. date --rfc-3339=ns
  43. for i in $(seq 1 2000); do
  44.     substrcmp "abc${i}def%Fzyx" '%F'
  45. done
  46. date --rfc-3339=ns
  47.  
  48. # 2018-04-19 00:40:49.647043516
  49. # 2018-04-19 00:40:49.656980633
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement