Skip to content
Snippets Groups Projects
Closed Performances issue on Transactions tab
  • View options
  • Performances issue on Transactions tab

    • View options
  • Closed created by inso

    Transactions tab is quite slow. Something should be done.

    Here is the result of the profiling of this tab :

    Wrote profile results to main.py.lprof
    Timer unit: 1e-06 s
    
    Total time: 14.8382 s
    File: /home/inso/code/ucoin/cutecoin/src/cutecoin/models/txhistory.py
    Function: data at line 61
    
    Line #      Hits         Time  Per Hit   % Time  Line Contents
    ==============================================================
        61                                               @profile
        62                                               def data(self, index, role):
        63     18092      2499260    138.1     16.8          source_index = self.mapToSource(index)
        64     18092      3506449    193.8     23.6          source_data = self.sourceModel().data(source_index, role)
        65     18092       890733     49.2      6.0          state_col = self.sourceModel().column_types.index('state')
        66     18092      3360753    185.8     22.6          state_index = self.sourceModel().index(source_index.row(), state_col)
        67     18092      3866937    213.7     26.1          state_data = self.sourceModel().data(state_index, Qt.DisplayRole)
        68     18092        29368      1.6      0.2          if role == Qt.DisplayRole:
        69      2326       115534     49.7      0.8              if source_index.column() == self.sourceModel().column_types.index('uid'):
        70       554          755      1.4      0.0                  return source_data
        71      1772        84513     47.7      0.6              if source_index.column() == self.sourceModel().column_types.index('date'):
        72       554         7169     12.9      0.0                  date = QDateTime.fromTime_t(source_data)
        73       554         1667      3.0      0.0                  return date.date()
        74      1218        57795     47.5      0.4              if source_index.column() == self.sourceModel().column_types.index('payment')  or \
        75       664        31396     47.3      0.2                  source_index.column() == self.sourceModel().column_types.index('deposit'):
        76      1108         1705      1.5      0.0                  if source_data is not "":
        77       554         2236      4.0      0.0                      amount_ref = self.account.units_to_diff_ref(source_data,
        78       554         2151      3.9      0.0                                                                  self.community)
        79                                           
        80       554         1000      1.8      0.0                      if type(amount_ref) is int:
        81       554          709      1.3      0.0                          formatter = "{0}"
        82                                                               else:
        83                                                                   formatter = "{0:.2f}"
        84                                           
        85       554         2774      5.0      0.0                      return formatter.format(amount_ref)
        86                                           
        87     16430        22864      1.4      0.2          if role == Qt.FontRole:
        88      2326         8462      3.6      0.1              font = QFont()
        89      2326         3737      1.6      0.0              if state_data == Transfer.AWAITING:
        90                                                           font.setItalic(True)
        91      2326         3111      1.3      0.0              elif state_data == Transfer.REFUSED:
        92                                                           font.setItalic(True)
        93      2326         3102      1.3      0.0              elif state_data == Transfer.TO_SEND:
        94                                                           font.setBold(True)
        95                                                       else:
        96      2326         6524      2.8      0.0                  font.setItalic(False)
        97      2326         2643      1.1      0.0              return font
        98                                           
        99     14104        22784      1.6      0.2          if role == Qt.ForegroundRole:
       100      2326         3233      1.4      0.0              if state_data == Transfer.REFUSED:
       101                                                           return QColor(Qt.red)
       102      2326         3033      1.3      0.0              elif state_data == Transfer.TO_SEND:
       103                                                           return QColor(Qt.blue)
       104                                           
       105     14104        20836      1.5      0.1          if role == Qt.TextAlignmentRole:
       106      2326       197263     84.8      1.3              if source_index.column() == self.sourceModel().column_types.index('deposit') or source_index.column() == self.sourceModel().column_types.index('payment'):
       107      1108         5407      4.9      0.0                  return Qt.AlignRight | Qt.AlignVCenter
       108      1218        57851     47.5      0.4              if source_index.column() == self.sourceModel().column_types.index('date'):
       109       554          963      1.7      0.0                  return Qt.AlignCenter
       110     12442        13506      1.1      0.1          return source_data
    
    Total time: 0.0983 s
    File: /home/inso/code/ucoin/cutecoin/src/cutecoin/models/txhistory.py
    Function: data_received at line 166
    
    Line #      Hits         Time  Per Hit   % Time  Line Contents
    ==============================================================
       166                                               @profile
       167                                               def data_received(self, transfer):
       168      8993        19806      2.2     20.1          amount = transfer.metadata['amount']
       169      8993         6901      0.8      7.0          comment = ""
       170      8993         7726      0.9      7.9          if transfer.txdoc:
       171      8993         8069      0.9      8.2              comment = transfer.txdoc.comment
       172      8993        14753      1.6     15.0          if transfer.metadata['issuer_uid'] != "":
       173      8533        12476      1.5     12.7              sender = transfer.metadata['issuer_uid']
       174                                                   else:
       175       460         2136      4.6      2.2              sender = "pub:{0}".format(transfer.metadata['issuer'][:5])
       176                                           
       177      8993        12788      1.4     13.0          date_ts = transfer.metadata['time']
       178                                           
       179      8993         6605      0.7      6.7          return (date_ts, sender, "", amount,
       180      8993         7040      0.8      7.2                  comment, transfer.state)
    
    Total time: 0.132468 s
    File: /home/inso/code/ucoin/cutecoin/src/cutecoin/models/txhistory.py
    Function: data_sent at line 182
    
    Line #      Hits         Time  Per Hit   % Time  Line Contents
    ==============================================================
       182                                               @profile
       183                                               def data_sent(self, transfer):
       184     12512        24197      1.9     18.3          amount = transfer.metadata['amount']
       185     12512         9423      0.8      7.1          comment = ""
       186     12512        10491      0.8      7.9          if transfer.txdoc:
       187     12512        11225      0.9      8.5              comment = transfer.txdoc.comment
       188                                           
       189     12512        20157      1.6     15.2          if transfer.metadata['receiver_uid'] != "":
       190     11678        16804      1.4     12.7              receiver = transfer.metadata['receiver_uid']
       191                                                   else:
       192       834         4084      4.9      3.1              receiver = "pub:{0}".format(transfer.metadata['receiver'][:5])
       193                                           
       194                                           
       195     12512        17444      1.4     13.2          date_ts = transfer.metadata['time']
       196                                           
       197     12512         8540      0.7      6.4          return (date_ts, receiver, amount,
       198     12512        10103      0.8      7.6                  "", comment, transfer.state)
    
    Total time: 5.47233 s
    File: /home/inso/code/ucoin/cutecoin/src/cutecoin/models/txhistory.py
    Function: data at line 200
    
    Line #      Hits         Time  Per Hit   % Time  Line Contents
    ==============================================================
       200                                               @profile
       201                                               def data(self, index, role):
       202     37271        54424      1.5      1.0          row = index.row()
       203     37271        33022      0.9      0.6          col = index.column()
       204                                           
       205     37271        33502      0.9      0.6          if not index.isValid():
       206                                                       return QVariant()
       207                                           
       208     37271      4806702    129.0     87.8          transfer = self.transfers[row]
       209     37271        46665      1.3      0.9          if role == Qt.DisplayRole:
       210     21505        21855      1.0      0.4              if type(transfer) is Received:
       211      8993       201109     22.4      3.7                  return self.data_received(transfer)[col]
       212                                                       else:
       213     12512       275051     22.0      5.0                  return self.data_sent(transfer)[col]
    

    Activity

    • All activity
    • Comments only
    • History only
    • Newest first
    • Oldest first