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

low performance in vtk_fortran_dataarray_encoder #34

Open
hjunqq opened this issue Jun 1, 2022 · 3 comments
Open

low performance in vtk_fortran_dataarray_encoder #34

hjunqq opened this issue Jun 1, 2022 · 3 comments
Assignees
Labels

Comments

@hjunqq
Copy link
Contributor

hjunqq commented Jun 1, 2022

the code like

  code = ''
  do n=1, size(x, dim=1)
    code = code//str(n=u(n))//' '//str(n=v(n))//' '//str(n=w(n))// &
                 str(n=x(n))//' '//str(n=y(n))//' '//str(n=z(n))
  enddo

in vtk_fortran_dataarray_encoder.f90
takes a long time to execute when a large amount of data needs to be processed

@szaghi
Copy link
Owner

szaghi commented Jun 1, 2022

Hi @hjunqq

I know, but vtk_fortran_dataarray_encoder is the encoder for ASCII files that are not tailored for a large amount of data.

If you have to write large files I strongly suggest using a raw binary encoder.

Kind regards

@szaghi szaghi self-assigned this Jun 1, 2022
@szaghi szaghi added the question label Jun 1, 2022
@hjunqq
Copy link
Contributor Author

hjunqq commented Jun 2, 2022

I modify the code like that:

  size_n = size(x,dim=1)
  l = DI1P+1
  sp = 0
  code = repeat(' ',l*size_n)
  do n = 1,size_n
      code(sp+1:sp+l) = str(n=x(n))
      sp = sp + l
  enddo

it has better performance, but doesnot as elegant as the code you wrote.
#35

@szaghi
Copy link
Owner

szaghi commented Jun 6, 2022

Hi @hjunqq
sorry for my delay. Yes, there is room for improvement, but for the ASCII encoder, I was focused on clearness, conciseness, and maintainability rather than performance just because for larger files the raw-binary encoder is the right option. Anyway, you patch is fine for me.

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants