How to improve response speed in a website, where a picture is drawn in real time at backend, using...











up vote
0
down vote

favorite












I hope to improve response speed as much as possible, and I test the time my drawing function, which spends 2.9~3.2 seconds.
Any tips to improve the speed are appreciated, from algorithm, program, website design...



The during time between 'user click draw button' and 'show picture in browser' is too long, using python and django, how can I reduce the time? Thanks in advance.



load 1.999396
angle2plane 3.0000000000196536e-05
getPoint 7.000000000090267e-06
getGrid 0.003222000000000058
D2MapD3 0.584085
getValue 0.032258999999999816
show 0.35327399999999987
total 2.982803

beg=time.clock()
ds=loadArray(filepath, (110,110,187))
end=time.clock()

print("load", str(end-beg))

ds=np.clip(ds, 0, 1)

print("alpha, beta, gamma:", alpha, beta, gamma)

beg=time.clock()
plane=angle2plane(alpha, beta, gamma, dis)
end=time.clock()
print("angle2plane", str(end-beg))

beg=time.clock()
A, B, C=getPoint(plane)
end=time.clock()
print("getPoint", str(end-beg))

beg=time.clock()
grid=getGrid(width, height)
end=time.clock()
print("getGrid", str(end-beg))

rowgrid=len(grid)
colgrid=len(grid[0])

beg=time.clock()
mpmatrix=D2MapD3(A, B, C, grid)
end=time.clock()

beg=time.clock()
values=getValue(mpmatrix, ds, width, height)
end=time.clock()
print("getValue", str(end-beg))

values=values.reshape(rowgrid, colgrid)

beg=time.clock()
plt.imshow(values)
plt.savefig("test.png")
end=time.clock()
print("show", str(end-beg))









share|improve this question






















  • apart from D2MapD3, the other long functions are loading and saving. What do you use to load and save (what storage?)
    – dirkgroten
    2 days ago















up vote
0
down vote

favorite












I hope to improve response speed as much as possible, and I test the time my drawing function, which spends 2.9~3.2 seconds.
Any tips to improve the speed are appreciated, from algorithm, program, website design...



The during time between 'user click draw button' and 'show picture in browser' is too long, using python and django, how can I reduce the time? Thanks in advance.



load 1.999396
angle2plane 3.0000000000196536e-05
getPoint 7.000000000090267e-06
getGrid 0.003222000000000058
D2MapD3 0.584085
getValue 0.032258999999999816
show 0.35327399999999987
total 2.982803

beg=time.clock()
ds=loadArray(filepath, (110,110,187))
end=time.clock()

print("load", str(end-beg))

ds=np.clip(ds, 0, 1)

print("alpha, beta, gamma:", alpha, beta, gamma)

beg=time.clock()
plane=angle2plane(alpha, beta, gamma, dis)
end=time.clock()
print("angle2plane", str(end-beg))

beg=time.clock()
A, B, C=getPoint(plane)
end=time.clock()
print("getPoint", str(end-beg))

beg=time.clock()
grid=getGrid(width, height)
end=time.clock()
print("getGrid", str(end-beg))

rowgrid=len(grid)
colgrid=len(grid[0])

beg=time.clock()
mpmatrix=D2MapD3(A, B, C, grid)
end=time.clock()

beg=time.clock()
values=getValue(mpmatrix, ds, width, height)
end=time.clock()
print("getValue", str(end-beg))

values=values.reshape(rowgrid, colgrid)

beg=time.clock()
plt.imshow(values)
plt.savefig("test.png")
end=time.clock()
print("show", str(end-beg))









share|improve this question






















  • apart from D2MapD3, the other long functions are loading and saving. What do you use to load and save (what storage?)
    – dirkgroten
    2 days ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I hope to improve response speed as much as possible, and I test the time my drawing function, which spends 2.9~3.2 seconds.
Any tips to improve the speed are appreciated, from algorithm, program, website design...



The during time between 'user click draw button' and 'show picture in browser' is too long, using python and django, how can I reduce the time? Thanks in advance.



load 1.999396
angle2plane 3.0000000000196536e-05
getPoint 7.000000000090267e-06
getGrid 0.003222000000000058
D2MapD3 0.584085
getValue 0.032258999999999816
show 0.35327399999999987
total 2.982803

beg=time.clock()
ds=loadArray(filepath, (110,110,187))
end=time.clock()

print("load", str(end-beg))

ds=np.clip(ds, 0, 1)

print("alpha, beta, gamma:", alpha, beta, gamma)

beg=time.clock()
plane=angle2plane(alpha, beta, gamma, dis)
end=time.clock()
print("angle2plane", str(end-beg))

beg=time.clock()
A, B, C=getPoint(plane)
end=time.clock()
print("getPoint", str(end-beg))

beg=time.clock()
grid=getGrid(width, height)
end=time.clock()
print("getGrid", str(end-beg))

rowgrid=len(grid)
colgrid=len(grid[0])

beg=time.clock()
mpmatrix=D2MapD3(A, B, C, grid)
end=time.clock()

beg=time.clock()
values=getValue(mpmatrix, ds, width, height)
end=time.clock()
print("getValue", str(end-beg))

values=values.reshape(rowgrid, colgrid)

beg=time.clock()
plt.imshow(values)
plt.savefig("test.png")
end=time.clock()
print("show", str(end-beg))









share|improve this question













I hope to improve response speed as much as possible, and I test the time my drawing function, which spends 2.9~3.2 seconds.
Any tips to improve the speed are appreciated, from algorithm, program, website design...



The during time between 'user click draw button' and 'show picture in browser' is too long, using python and django, how can I reduce the time? Thanks in advance.



load 1.999396
angle2plane 3.0000000000196536e-05
getPoint 7.000000000090267e-06
getGrid 0.003222000000000058
D2MapD3 0.584085
getValue 0.032258999999999816
show 0.35327399999999987
total 2.982803

beg=time.clock()
ds=loadArray(filepath, (110,110,187))
end=time.clock()

print("load", str(end-beg))

ds=np.clip(ds, 0, 1)

print("alpha, beta, gamma:", alpha, beta, gamma)

beg=time.clock()
plane=angle2plane(alpha, beta, gamma, dis)
end=time.clock()
print("angle2plane", str(end-beg))

beg=time.clock()
A, B, C=getPoint(plane)
end=time.clock()
print("getPoint", str(end-beg))

beg=time.clock()
grid=getGrid(width, height)
end=time.clock()
print("getGrid", str(end-beg))

rowgrid=len(grid)
colgrid=len(grid[0])

beg=time.clock()
mpmatrix=D2MapD3(A, B, C, grid)
end=time.clock()

beg=time.clock()
values=getValue(mpmatrix, ds, width, height)
end=time.clock()
print("getValue", str(end-beg))

values=values.reshape(rowgrid, colgrid)

beg=time.clock()
plt.imshow(values)
plt.savefig("test.png")
end=time.clock()
print("show", str(end-beg))






python django draw






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









Jason

1




1












  • apart from D2MapD3, the other long functions are loading and saving. What do you use to load and save (what storage?)
    – dirkgroten
    2 days ago


















  • apart from D2MapD3, the other long functions are loading and saving. What do you use to load and save (what storage?)
    – dirkgroten
    2 days ago
















apart from D2MapD3, the other long functions are loading and saving. What do you use to load and save (what storage?)
– dirkgroten
2 days ago




apart from D2MapD3, the other long functions are loading and saving. What do you use to load and save (what storage?)
– dirkgroten
2 days ago












1 Answer
1






active

oldest

votes

















up vote
0
down vote













If it is a long running task,

you can try,
Using Celery with WebSockets

You can initiate a celery worker (refer here) to do the long running job and return the
results via websocket (django channels)






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372922%2fhow-to-improve-response-speed-in-a-website-where-a-picture-is-drawn-in-real-tim%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    If it is a long running task,

    you can try,
    Using Celery with WebSockets

    You can initiate a celery worker (refer here) to do the long running job and return the
    results via websocket (django channels)






    share|improve this answer

























      up vote
      0
      down vote













      If it is a long running task,

      you can try,
      Using Celery with WebSockets

      You can initiate a celery worker (refer here) to do the long running job and return the
      results via websocket (django channels)






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        If it is a long running task,

        you can try,
        Using Celery with WebSockets

        You can initiate a celery worker (refer here) to do the long running job and return the
        results via websocket (django channels)






        share|improve this answer












        If it is a long running task,

        you can try,
        Using Celery with WebSockets

        You can initiate a celery worker (refer here) to do the long running job and return the
        results via websocket (django channels)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        Rejo Chandran

        15013




        15013






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372922%2fhow-to-improve-response-speed-in-a-website-where-a-picture-is-drawn-in-real-tim%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Volksrepublik China

            How to test boost logger output in unit testing?

            Write to the output between two pipeline