.. index:: halstead_metric(Stroud)
.. _halstead_metric/1:

.. rst-class:: right

**object**

``halstead_metric(Stroud)``
===========================

* ``Stroud`` - Coefficient for computing the time required to program.


Computes Halstead complexity numbers for an entity.

| **Author:** Paulo Moura
| **Version:** 0:7:0
| **Date:** 2018-07-18

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Imports:**
|    ``public`` :ref:`code_metrics_utilities <code_metrics_utilities/0>`
|    ``public`` :ref:`code_metric <code_metric/0>`
| **Uses:**
|    :ref:`list <list/0>`
|    :ref:`numberlist <numberlist/0>`
|    :ref:`pairs <pairs/0>`

| **Remarks:**

   - Definition of operators: Predicates declared, user-defined, and called are interpreted as operators. Built-in predicates and built-in control constructs are ignored.
   - Definition of operands: Predicate arguments are abstracted and interpreted as operands. Note that this definition of operands is a significant deviation from the original definition, which used syntactic literals.
   - Pn: Number of distinct predicates (declared, defined, called, or updated)
   - PAn: Number of predicate arguments (assumed distinct)
   - Cn: Number of predicate calls/updates + number of clauses
   - CAn: Number of predicate call/update arguments + number of clause head arguments
   - EV: Entity vocabulary: ``EV = Pn + PAn``
   - EL: Entity length: ``EL = Cn + CAn``
   - V: Volume: ``V = EL * log2(EV)``
   - D: Difficulty: ``D = (Pn/2) * (CAn/An)``
   - E: Effort: ``E = D * V``
   - T: Time required to program: ``T = E/k`` seconds (``k`` is the Stroud number; defaults to 18)
   - B: Number of delivered bugs: ``B = V/3000``
   - Entity score: Represented as the compound term ``pn_pan_cn_can_ev_el_v_d_e_t_b/11``.

| **Inherited public predicates:**
|     :ref:`code_metric/0::all/0`  :ref:`code_metric/0::all_score/1`  :ref:`code_metric/0::directory/1`  :ref:`code_metric/0::directory_score/2`  :ref:`code_metric/0::entity/1`  :ref:`code_metric/0::entity_score/2`  :ref:`code_metric/0::entity_score//2`  :ref:`code_metric/0::file/1`  :ref:`code_metric/0::file_score/2`  :ref:`code_metric/0::library/1`  :ref:`code_metric/0::library_score/2`  :ref:`code_metric/0::rdirectory/1`  :ref:`code_metric/0::rdirectory_score/2`  :ref:`code_metric/0::rlibrary/1`  :ref:`code_metric/0::rlibrary_score/2`  

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

(no local declarations; see entity ancestors if any)

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

