sss
sssunknown
csharp
2 years ago
1.6 kB
3
Indexable
Never
ScenarAarray::ScenarAarray() : SimpleTest("Scenar A, Array") { } void ScenarAarray::test() { this->logInfo("Koniec testu"); srand(time(NULL)); double randomNum = 0; int pocet = 100000; structures::List<int>* list = new structures::ArrayList<int>(); for (int i = 0; i < 500; i++) { list->add(i); } while (pocet != 0) { randomNum = rand() % 100; if (randomNum < 20) { // insert int nahodnyIndex = rand() % list->size(); this->startStopwatch(); list->insert(0, nahodnyIndex); this->stopStopwatch(); structures::Logger::getInstance().logDuration(list->size(), this->getElapsedTime(), "INSERT"); } else if (randomNum < 40) { // RemoveAt int nahodnyIndex = rand() % list->size(); this->startStopwatch(); list->removeAt(nahodnyIndex); this->stopStopwatch(); structures::Logger::getInstance().logDuration(list->size(), this->getElapsedTime(), "REMOVE AT"); } else if (randomNum < 90) { // At int nahodnyIndex = rand() % list->size(); this->startStopwatch(); list->at(nahodnyIndex); this->stopStopwatch(); structures::Logger::getInstance().logDuration(list->size(), this->getElapsedTime(), "AT"); } else { // GetIndexOf int nahodnyIndex = rand() % list->size(); this->startStopwatch(); list->getIndexOf(nahodnyIndex); this->stopStopwatch(); structures::Logger::getInstance().logDuration(list->size(), this->getElapsedTime(), "GET INDEX OF"); } pocet--; } delete list; }