Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from arrays to hashtables #68

Closed
vezaynk opened this issue Jan 22, 2018 · 1 comment
Closed

Switch from arrays to hashtables #68

vezaynk opened this issue Jan 22, 2018 · 1 comment

Comments

@vezaynk
Copy link
Owner

vezaynk commented Jan 22, 2018

The current implementation uses arrays and iterates them to search for values. With sites such as codinghorror, it starts to become slow because of its O(n) complexity. Meanwhile, hashtables offer the same exact functionality but with O(1) complexity.

Before:

time php sitemap.php site=https://blog.codinghorror.com
 [+] Sitemap has been generated in 746.65 secondsand saved to sitemap.xml
 [+] Scanned a total of 3137 pages and indexed 1704 pages.
 [+] Operation Completed
php sitemap.php site=https://blog.codinghorror.com  6.04s user 1.42s system 0% cpu 12:26.71 total

After:

time php sitemap.php site=https://blog.codinghorror.com
 [+] Sitemap has been generatedin 570.19 secondsand saved to sitemap.xml
 [+] Scanned a total of 3137 pages and indexed 1704 pages.
 [+] Operation Completed
php sitemap.php site=https://blog.codinghorror.com  4.67s user 1.45s system 1% cpu 9:30.23 tota

Performance difference on server is negligible.

#26

@vezaynk
Copy link
Owner Author

vezaynk commented Jan 22, 2018

Pushed in 4b0a38f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant