Skip to content

Hw04 GC Compare - #4

Open
1121977 wants to merge 10 commits into
masterfrom
hw04-GCCompare
Open

Hw04 GC Compare#4
1121977 wants to merge 10 commits into
masterfrom
hw04-GCCompare

Conversation

@1121977

@1121977 1121977 commented Nov 2, 2020

Copy link
Copy Markdown
Owner

No description provided.

while (true){
int currentSize = dateArray.size();
System.out.println("currentSize is " + currentSize);
for (int i=currentSize-1;i>=currentSize-(currentSize>>1);i--){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ой как сложно половину выделили. currentSize/2 и проще и быстрее чем currentSize - (currentSize>>1). И полностью эквивалентно currentSize>>1

dateArray.remove((int) (Math.random()*dateArray.size()));
}
for (int i = 0; i < currentSize; i++) {
dateArray.add(new Date());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не очень удачное решение для заполнения массива. в течении одной миллисекунды будет 1 Date для всех записей. Так Java оптимизирует память.

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

Successfully merging this pull request may close these issues.

2 participants