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

3x faster getError member function of GroupSync&BulkRead Class #388

Closed
wants to merge 2 commits into from

Conversation

developer0hye
Copy link

@developer0hye developer0hye commented Mar 24, 2020

removed condition state so that we can reduce the stall caused by the branch statement.

The below code is the test code.

#include <iostream>
#include <time.h>

using namespace std;

uint8_t error_list[1000];

bool getErrorAnchor(int id, uint8_t* error)
{
    error[id] = error_list[id];

    if(error[id] != 0) return true;
    else return false;
}

bool getErrorProposed(int id, uint8_t* error)
{
    return error[id] = error_list[id];
}


int main()
{
    for(int i = 0; i < 1000; i++)
    {
        error_list[i] = rand()%2;
    }

    uint8_t error[1000];

    clock_t begin, end;
    begin = clock();

    for (int n = 0; n < 100000; n++)
        for(int i = 0; i < 1000; i++)
        {
            getErrorAnchor(i, error);
        }
    end = clock();
    cout<<"Execution time _testAnchor : "<<((double)(end-begin)/CLOCKS_PER_SEC)<<endl;

    begin = clock();

    for (int n = 0; n < 100000; n++)
        for(int i = 0; i < 1000; i++)
        {
            getErrorProposed(i, error);
        }
    end = clock();
    cout<<"Execution time _testProposed : "<<((double)(end-begin)/CLOCKS_PER_SEC)<<endl;
    return 0;
}

I got the results shown here.

Execution time _testAnchor : 0.858
Execution time _testProposed : 0.263

removed condition state so that we can reduce the stall caused by the branch statement.
removed condition state so that we can reduce the stall caused by the branch statement.
@developer0hye developer0hye changed the title 4x faster getError member function of GroupSync&BulkRead Class 3x faster getError member function of GroupSync&BulkRead Class Mar 24, 2020
@developer0hye developer0hye deleted the patch-1 branch July 15, 2020 06:42
ROBOTIS-Will added a commit that referenced this pull request Jul 15, 2020
smkaeser added a commit to WeRobotics/DynamixelSDK that referenced this pull request Jan 14, 2021
* Non-standard baudrates are supported on the latest Mac OS

* - added clear instruction & example

* fixed bug removeStuffing

* - added clear instruction

* added clear_multi_turn example

* remove python build

* - reduced TXPACKET_MAX_LEN & RXPACKET_MAX_LEN (4K -> 1K)
  because the size of most Dynamixel receive buffers is 1K.
- checked whether memory allocation was successful.
- marked the crc table as static const
- changed addStuffing() function (reduced stack memory usage)
- removed busy waiting for rxPacket()
- fixed the broadcastping bug in dxl_monitor

* - modified "ros" directory C++ code.

* added clearmultiturn packet handler

* added ros clearMultiTurn API

* modified ros clear multi turn

* sync opencjr

* sync opencm

* add macro

* updated the CHANGELOG and version to release binary packages

* Update bulk_read_write.py

fixed typo.

* - updated c lib & dll file.

* fixed typo.

* - fixed "protocol_combined" example bug

* - changed C# / win32 / protocol_combined output path.

* Updated the CHANGELOG and version to release binary packages

Signed-off-by: Pyo <pyo@robotis.com>

* Updated the CHANGELOG and version to release binary packages

Signed-off-by: Pyo <pyo@robotis.com>

* Update README.md

* - fixed buffer overflow bug (rxpacket size)

* Fixed buffer overflow bug (rxpacket size)

Signed-off-by: Pyo <pyo@robotis.com>

* Added change log information

Signed-off-by: Pyo <pyo@robotis.com>

* Fixed typo in the package.xml and header files

Signed-off-by: Pyo <pyo@robotis.com>

* Added imports to __init__.py in ros package.

* - packet timeout in broadcastPing() overflow bug fixed.
- bug in python removeStuffing() fixed.

* - fixed "conflicting types for 'reboot'" error in mac OS.

* Fix two potential memory leaks. (ROBOTIS-GIT#361)
- Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

* - fixed memory leak issue (group sync/bulk series)

* - fixed an issue loading the wrong library (in x86)

* 3x faster getError member function of GroupSync&BulkRead Class ROBOTIS-GIT#388

* Update setup.py

changed the version of Dynamixel SDK

* support noetic

* update version info

* resolve package name conflict

* revise ROS1 version

* DynamixelSDK_ros_examples

* update comment

* Update CMakeLists.txt

* - modified setCustomBaudrate() function. (ROBOTIS-GIT#430)

* update changelog

* update issue template

* update issue template

* Update read_write.py

- position length bug fixed.

Co-authored-by: kizitorashiro <kizitora.shiro@gmail.com>
Co-authored-by: Pyo <pyo@robotis.com>
Co-authored-by: zerom <zerom@robotis.com>
Co-authored-by: kijonggil <kkjong@robotis.com>
Co-authored-by: Darby Lim <thlim@robotis.com>
Co-authored-by: guichristmann <guichristmann@gmail.com>
Co-authored-by: Will Son <willson@robotis.com>
Co-authored-by: Ryan Jaehyun Shim <38637417+rjshim@users.noreply.github.com>
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