Giter VIP home page Giter VIP logo

Comments (4)

buzdin avatar buzdin commented on June 2, 2024

Try to use copy-by-reference option not to create a separate array. As far as I know we do use System.arrayCopy in some places. If you could profile and see where it is missing would be great.

from dozer.

Spikhalskiy avatar Spikhalskiy commented on June 2, 2024

Please, could you provide a code of concrete test case? Maybe, I will research it in the nearest future and try to fix.
BTW, feel free to submit patch :)

from dozer.

sebastiencaille avatar sebastiencaille commented on June 2, 2024

Hello, test case below.

In the head version of Dozer, the time is spent in MappingProcessor.addToPrimitiveArray .
It is much easier to fix than in previous release.

btw, my initial post was wrong concerning the immutables types. Maybe System.arrayCopy could also be used for types that are both "copy-by-reference" and final.
It could be useful for String[]

The following TC outputs ~1000 (ms) on my machine

public class DozerPerformanceTest extends TestCase {

public static class ByteTest {
    private byte[] data;

    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }
}

public void testByteCopy() {

    RootLogger.getRootLogger().setLevel(Level.WARN);

    ByteTest test = new ByteTest();
    test.setData(new byte[1024 * 1024]);
    DozerBeanMapper dozer = new DozerBeanMapper();
    ByteTest map = dozer.map(test, ByteTest.class);

    long start = System.currentTimeMillis();
    map = dozer.map(test, ByteTest.class);
    System.out.println(System.currentTimeMillis() - start);

}

}

from dozer.

buzdin avatar buzdin commented on June 2, 2024

This part of the code handles mixed element collections, but your final + copy-by-reference is a perfect solution how to distinguish the need for System.arrayCopy()!

So the solution should be - if it is a typed collection and type is final and copy-by-referenced, then do native array copy.

from dozer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.