Skip to content
New issue

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

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

Already on GitHub? # to your account

Speed Optimization: get_state_planes() #133

Merged
merged 1 commit into from
Jun 8, 2021
Merged

Conversation

QueensGambit
Copy link
Owner

@QueensGambit QueensGambit commented Jun 8, 2021

  • speed optimization for get_state_planes()
    float* inputPlanes = new float[StateConstants::NB_VALUES_TOTAL()];
    BoardState state;
    int it = 100000;

    // Get starting timepoint
    auto start = high_resolution_clock::now();

    for (int i = 0; i < it; ++i) {
        state.get_state_planes(false, inputPlanes);
    }

    // Get ending timepoint
    auto stop = high_resolution_clock::now();

    // Get duration. Substart timepoints to
    // get durarion. To cast it to proper unit
    // use duration cast method
    auto duration = duration_cast<microseconds>(stop - start);

    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;

   delete []inputPlanes;

Before:

  • Time taken by function: 37 732 microseconds

Now:

  • Time taken by function: 32 311 microseconds

Speed-up by about 14%.

100 000 iterations

Before:
Time taken by function: 37732 microseconds

Now:
Time taken by function: 32311 microseconds

Speed-up by about 14%
@QueensGambit QueensGambit merged commit 51bb64f into master Jun 8, 2021
@QueensGambit QueensGambit deleted the get_state_planes branch June 30, 2021 11:44
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant